about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2013-05-05 15:11:04 -0400
committerNiko Matsakis <niko@alum.mit.edu>2013-05-05 15:11:04 -0400
commit4300d4d2fa9d35ac73742c7d815ee157ce0f9c17 (patch)
tree9e5db5a04493a573f280b2c8863d0eaf0ca47c0d
parent6cb273ed4efb6724b1c713c3ac35d14e52999fb1 (diff)
parent063851ffa1b8388a0b70446c0209af16264e8181 (diff)
downloadrust-4300d4d2fa9d35ac73742c7d815ee157ce0f9c17.tar.gz
rust-4300d4d2fa9d35ac73742c7d815ee157ce0f9c17.zip
Merge remote-tracking branch 'mozilla/incoming' into issue-5910-dyna-freeze
Conflicts:
	src/libcore/core.rc
	src/libcore/hashmap.rs
	src/libcore/num/f32.rs
	src/libcore/num/f64.rs
	src/libcore/num/float.rs
	src/libcore/num/int-template.rs
	src/libcore/num/num.rs
	src/libcore/num/strconv.rs
	src/libcore/num/uint-template.rs
	src/libcore/ops.rs
	src/libcore/os.rs
	src/libcore/prelude.rs
	src/libcore/rt/mod.rs
	src/libcore/unstable/lang.rs
	src/librustc/driver/session.rs
	src/librustc/middle/astencode.rs
	src/librustc/middle/borrowck/check_loans.rs
	src/librustc/middle/borrowck/gather_loans.rs
	src/librustc/middle/borrowck/loan.rs
	src/librustc/middle/borrowck/preserve.rs
	src/librustc/middle/liveness.rs
	src/librustc/middle/mem_categorization.rs
	src/librustc/middle/region.rs
	src/librustc/middle/trans/base.rs
	src/librustc/middle/trans/inline.rs
	src/librustc/middle/trans/reachable.rs
	src/librustc/middle/typeck/check/_match.rs
	src/librustc/middle/typeck/check/regionck.rs
	src/librustc/util/ppaux.rs
	src/libstd/arena.rs
	src/libstd/ebml.rs
	src/libstd/json.rs
	src/libstd/serialize.rs
	src/libstd/std.rc
	src/libsyntax/ast_map.rs
	src/libsyntax/parse/parser.rs
	src/test/compile-fail/borrowck-uniq-via-box.rs
	src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs
	src/test/run-pass/borrowck-nested-calls.rs
-rw-r--r--.gitattributes9
-rw-r--r--COPYRIGHT1
-rw-r--r--Makefile.in2
-rw-r--r--RELEASES.txt6
-rw-r--r--doc/README6
-rw-r--r--doc/rust.md9
-rw-r--r--doc/tutorial-ffi.md11
-rw-r--r--doc/tutorial-macros.md1
-rw-r--r--doc/tutorial-tasks.md1
-rw-r--r--doc/tutorial.md8
-rw-r--r--doc/version_info.html.template1
-rw-r--r--mk/clean.mk2
-rw-r--r--mk/docs.mk74
-rw-r--r--mk/host.mk38
-rw-r--r--mk/platform.mk6
-rw-r--r--mk/rt.mk22
-rw-r--r--mk/stage0.mk6
-rw-r--r--mk/target.mk32
-rw-r--r--mk/tests.mk5
-rw-r--r--src/compiletest/compiletest.rc7
-rwxr-xr-xsrc/etc/check-links.pl5
-rw-r--r--src/etc/gedit/readme.txt1
-rw-r--r--src/etc/gedit/share/gtksourceview-3.0/language-specs/rust.lang5
-rw-r--r--src/etc/gedit/share/mime/packages/rust.xml2
-rwxr-xr-xsrc/etc/indenter1
-rwxr-xr-xsrc/etc/latest-unix-snaps.py2
-rw-r--r--src/etc/libc.c1
-rw-r--r--src/etc/licenseck.py1
-rwxr-xr-xsrc/etc/local_stage0.sh4
-rw-r--r--src/etc/mirror-all-snapshots.py3
-rwxr-xr-xsrc/etc/monodebug.pl1
-rwxr-xr-xsrc/etc/sugarise-doc-comments.py1
-rw-r--r--src/etc/tidy.py1
-rwxr-xr-xsrc/etc/unicode.py4
-rw-r--r--src/etc/x86.supp4
-rwxr-xr-xsrc/etc/ziggurat_tables.py121
-rw-r--r--src/libcore/bool.rs2
-rw-r--r--src/libcore/cast.rs44
-rw-r--r--src/libcore/char.rs1
-rw-r--r--src/libcore/cleanup.rs1
-rw-r--r--src/libcore/condition.rs23
-rw-r--r--src/libcore/core.rc16
-rw-r--r--src/libcore/either.rs10
-rw-r--r--src/libcore/hashmap.rs4
-rw-r--r--src/libcore/io.rs10
-rw-r--r--src/libcore/iter.rs93
-rw-r--r--src/libcore/iterator.rs21
-rw-r--r--src/libcore/libc.rs248
-rw-r--r--src/libcore/logging.rs1
-rw-r--r--src/libcore/macros.rs39
-rw-r--r--src/libcore/num/cmath.rs11
-rw-r--r--src/libcore/num/f32.rs21
-rw-r--r--src/libcore/num/f64.rs20
-rw-r--r--src/libcore/num/float.rs21
-rw-r--r--src/libcore/num/int-template.rs119
-rw-r--r--src/libcore/num/num.rs26
-rw-r--r--src/libcore/num/strconv.rs12
-rw-r--r--src/libcore/num/uint-template.rs27
-rw-r--r--src/libcore/ops.rs6
-rw-r--r--src/libcore/option.rs8
-rw-r--r--src/libcore/os.rs155
-rw-r--r--src/libcore/owned.rs1
-rw-r--r--src/libcore/pipes.rs38
-rw-r--r--src/libcore/prelude.rs5
-rw-r--r--src/libcore/rand.rs15
-rw-r--r--src/libcore/rand/distributions.rs148
-rw-r--r--src/libcore/rand/ziggurat_tables.rs412
-rw-r--r--src/libcore/repr.rs2
-rw-r--r--src/libcore/rt/context.rs1
-rw-r--r--src/libcore/rt/io/comm_adapters.rs1
-rw-r--r--src/libcore/rt/io/extensions.rs (renamed from src/libcore/rt/io/util.rs)0
-rw-r--r--src/libcore/rt/io/file.rs10
-rw-r--r--src/libcore/rt/io/mem.rs69
-rw-r--r--src/libcore/rt/io/mod.rs246
-rw-r--r--src/libcore/rt/io/net/ip.rs1
-rw-r--r--src/libcore/rt/io/net/tcp.rs30
-rw-r--r--src/libcore/rt/io/net/udp.rs6
-rw-r--r--src/libcore/rt/io/net/unix.rs8
-rw-r--r--src/libcore/rt/io/option.rs153
-rw-r--r--src/libcore/rt/io/support.rs (renamed from src/libcore/rt/io/misc.rs)0
-rw-r--r--src/libcore/rt/local_heap.rs80
-rw-r--r--src/libcore/rt/local_services.rs223
-rw-r--r--src/libcore/rt/mod.rs51
-rw-r--r--src/libcore/rt/sched/local_sched.rs1
-rw-r--r--src/libcore/rt/sched/mod.rs21
-rw-r--r--src/libcore/rt/test.rs120
-rw-r--r--src/libcore/rt/uv/mod.rs6
-rw-r--r--src/libcore/rt/uv/net.rs64
-rw-r--r--src/libcore/rt/uvio.rs124
-rw-r--r--src/libcore/rt/uvll.rs6
-rw-r--r--src/libcore/run.rs413
-rw-r--r--src/libcore/stackwalk.rs4
-rw-r--r--src/libcore/str.rs147
-rw-r--r--src/libcore/str/ascii.rs2
-rw-r--r--src/libcore/sys.rs54
-rw-r--r--src/libcore/task/local_data.rs11
-rw-r--r--src/libcore/task/local_data_priv.rs88
-rw-r--r--src/libcore/task/mod.rs110
-rw-r--r--src/libcore/task/spawn.rs8
-rw-r--r--src/libcore/to_bytes.rs3
-rw-r--r--src/libcore/unicode.rs3
-rw-r--r--src/libcore/unstable/exchange_alloc.rs1
-rw-r--r--src/libcore/unstable/extfmt.rs8
-rw-r--r--src/libcore/unstable/intrinsics.rs4
-rw-r--r--src/libcore/unstable/lang.rs41
-rw-r--r--src/libcore/unstable/weak_task.rs1
-rw-r--r--src/libcore/vec.rs8
-rw-r--r--src/libfuzzer/fuzzer.rc7
-rw-r--r--src/librustc/back/abi.rs16
-rw-r--r--src/librustc/back/arm.rs11
-rw-r--r--src/librustc/back/link.rs191
-rw-r--r--src/librustc/back/mips.rs11
-rw-r--r--src/librustc/back/rpath.rs2
-rw-r--r--src/librustc/back/upcall.rs9
-rw-r--r--src/librustc/back/x86.rs10
-rw-r--r--src/librustc/back/x86_64.rs10
-rw-r--r--src/librustc/driver/driver.rs135
-rw-r--r--src/librustc/driver/session.rs51
-rw-r--r--src/librustc/front/config.rs8
-rw-r--r--src/librustc/front/test.rs19
-rw-r--r--src/librustc/lib/llvm.rs10
-rw-r--r--src/librustc/metadata/common.rs2
-rw-r--r--src/librustc/metadata/creader.rs8
-rw-r--r--src/librustc/metadata/csearch.rs15
-rw-r--r--src/librustc/metadata/cstore.rs8
-rw-r--r--src/librustc/metadata/decoder.rs27
-rw-r--r--src/librustc/metadata/encoder.rs286
-rw-r--r--src/librustc/metadata/filesearch.rs55
-rw-r--r--src/librustc/metadata/loader.rs2
-rw-r--r--src/librustc/metadata/mod.rs1
-rw-r--r--src/librustc/metadata/tydecode.rs10
-rw-r--r--src/librustc/metadata/tyencode.rs10
-rw-r--r--src/librustc/middle/astencode.rs472
-rw-r--r--src/librustc/middle/borrowck/check_loans.rs4
-rw-r--r--src/librustc/middle/borrowck/gather_loans/mod.rs3
-rw-r--r--src/librustc/middle/borrowck/mod.rs7
-rw-r--r--src/librustc/middle/check_const.rs38
-rw-r--r--src/librustc/middle/check_loop.rs6
-rw-r--r--src/librustc/middle/check_match.rs36
-rw-r--r--src/librustc/middle/const_eval.rs19
-rw-r--r--src/librustc/middle/freevars.rs8
-rw-r--r--src/librustc/middle/kind.rs63
-rw-r--r--src/librustc/middle/lang_items.rs11
-rw-r--r--src/librustc/middle/lint.rs69
-rw-r--r--src/librustc/middle/liveness.rs29
-rw-r--r--src/librustc/middle/mem_categorization.rs2
-rw-r--r--src/librustc/middle/moves.rs4
-rw-r--r--src/librustc/middle/pat_util.rs1
-rw-r--r--src/librustc/middle/privacy.rs77
-rw-r--r--src/librustc/middle/region.rs6
-rw-r--r--src/librustc/middle/resolve.rs27
-rw-r--r--src/librustc/middle/resolve_stage0.rs43
-rw-r--r--src/librustc/middle/subst.rs1
-rw-r--r--src/librustc/middle/trans/_match.rs11
-rw-r--r--src/librustc/middle/trans/adt.rs4
-rw-r--r--src/librustc/middle/trans/base.rs166
-rw-r--r--src/librustc/middle/trans/build.rs10
-rw-r--r--src/librustc/middle/trans/cabi.rs1
-rw-r--r--src/librustc/middle/trans/callee.rs5
-rw-r--r--src/librustc/middle/trans/closure.rs1
-rw-r--r--src/librustc/middle/trans/common.rs10
-rw-r--r--src/librustc/middle/trans/consts.rs37
-rw-r--r--src/librustc/middle/trans/controlflow.rs1
-rw-r--r--src/librustc/middle/trans/datum.rs5
-rw-r--r--src/librustc/middle/trans/debuginfo.rs26
-rw-r--r--src/librustc/middle/trans/expr.rs13
-rw-r--r--src/librustc/middle/trans/foreign.rs2
-rw-r--r--src/librustc/middle/trans/glue.rs51
-rw-r--r--src/librustc/middle/trans/inline.rs127
-rw-r--r--src/librustc/middle/trans/machine.rs1
-rw-r--r--src/librustc/middle/trans/macros.rs1
-rw-r--r--src/librustc/middle/trans/meth.rs26
-rw-r--r--src/librustc/middle/trans/monomorphize.rs17
-rw-r--r--src/librustc/middle/trans/reachable.rs27
-rw-r--r--src/librustc/middle/trans/reflect.rs1
-rw-r--r--src/librustc/middle/trans/shape.rs1
-rw-r--r--src/librustc/middle/trans/tvec.rs14
-rw-r--r--src/librustc/middle/trans/type_use.rs4
-rw-r--r--src/librustc/middle/ty.rs161
-rw-r--r--src/librustc/middle/typeck/astconv.rs31
-rw-r--r--src/librustc/middle/typeck/check/_match.rs286
-rw-r--r--src/librustc/middle/typeck/check/demand.rs2
-rw-r--r--src/librustc/middle/typeck/check/method.rs14
-rw-r--r--src/librustc/middle/typeck/check/mod.rs121
-rw-r--r--src/librustc/middle/typeck/check/regionck.rs10
-rw-r--r--src/librustc/middle/typeck/check/vtable.rs4
-rw-r--r--src/librustc/middle/typeck/coherence.rs53
-rw-r--r--src/librustc/middle/typeck/collect.rs30
-rw-r--r--src/librustc/middle/typeck/infer/combine.rs13
-rw-r--r--src/librustc/middle/typeck/infer/glb.rs1
-rw-r--r--src/librustc/middle/typeck/infer/macros.rs1
-rw-r--r--src/librustc/middle/typeck/infer/mod.rs27
-rw-r--r--src/librustc/middle/typeck/infer/region_inference.rs9
-rw-r--r--src/librustc/middle/typeck/infer/resolve.rs1
-rw-r--r--src/librustc/middle/typeck/infer/sub.rs1
-rw-r--r--src/librustc/middle/typeck/infer/unify.rs2
-rw-r--r--src/librustc/middle/typeck/mod.rs17
-rw-r--r--src/librustc/rustc.rc9
-rw-r--r--src/librustc/util/common.rs10
-rw-r--r--src/librustc/util/ppaux.rs8
-rw-r--r--src/librustdoc/path_pass.rs1
-rw-r--r--src/librustdoc/tystr_pass.rs15
-rw-r--r--src/librustpkg/conditions.rs10
-rw-r--r--src/librustpkg/context.rs3
-rw-r--r--src/librustpkg/path_util.rs136
-rw-r--r--src/librustpkg/rustpkg.rc159
-rw-r--r--src/librustpkg/tests.rs118
-rw-r--r--src/librustpkg/testsuite/pass/commands.txt1
-rw-r--r--src/librustpkg/testsuite/pass/src/deeply/nested/path/foo/src/main.rs1
-rw-r--r--src/librustpkg/util.rs12
-rw-r--r--src/libstd/arena.rs107
-rw-r--r--src/libstd/bitv.rs10
-rw-r--r--src/libstd/cmp.rs2
-rw-r--r--src/libstd/dbg.rs8
-rw-r--r--src/libstd/deque.rs2
-rw-r--r--src/libstd/ebml.rs467
-rw-r--r--src/libstd/flatpipes.rs17
-rw-r--r--src/libstd/getopts.rs8
-rw-r--r--src/libstd/json.rs530
-rw-r--r--src/libstd/list.rs33
-rw-r--r--src/libstd/net_tcp.rs2
-rw-r--r--src/libstd/net_url.rs10
-rw-r--r--src/libstd/num/bigint.rs149
-rw-r--r--src/libstd/num/complex.rs6
-rw-r--r--src/libstd/num/rational.rs8
-rw-r--r--src/libstd/serialize.rs581
-rw-r--r--src/libstd/sha1.rs8
-rw-r--r--src/libstd/sort.rs8
-rw-r--r--src/libstd/std.rc8
-rw-r--r--src/libstd/task_pool.rs1
-rw-r--r--src/libstd/tempfile.rs72
-rw-r--r--src/libstd/term.rs7
-rw-r--r--src/libstd/test.rs9
-rw-r--r--src/libstd/workcache.rs16
-rw-r--r--src/libsyntax/ast.rs51
-rw-r--r--src/libsyntax/ast_map.rs37
-rw-r--r--src/libsyntax/ast_util.rs48
-rw-r--r--src/libsyntax/attr.rs10
-rw-r--r--src/libsyntax/codemap.rs18
-rw-r--r--src/libsyntax/ext/asm.rs12
-rw-r--r--src/libsyntax/ext/auto_encode.rs304
-rw-r--r--src/libsyntax/ext/base.rs12
-rw-r--r--src/libsyntax/ext/deriving/decodable.rs49
-rw-r--r--src/libsyntax/ext/deriving/encodable.rs42
-rw-r--r--src/libsyntax/ext/env.rs10
-rw-r--r--src/libsyntax/ext/expand.rs10
-rw-r--r--src/libsyntax/ext/fmt.rs15
-rw-r--r--src/libsyntax/ext/pipes/check.rs1
-rw-r--r--src/libsyntax/ext/pipes/liveness.rs1
-rw-r--r--src/libsyntax/ext/pipes/mod.rs1
-rw-r--r--src/libsyntax/ext/pipes/pipec.rs4
-rw-r--r--src/libsyntax/ext/pipes/proto.rs1
-rw-r--r--src/libsyntax/ext/quote.rs1
-rw-r--r--src/libsyntax/ext/source_util.rs10
-rw-r--r--src/libsyntax/ext/tt/macro_parser.rs8
-rw-r--r--src/libsyntax/fold.rs43
-rw-r--r--src/libsyntax/parse/attr.rs10
-rw-r--r--src/libsyntax/parse/lexer.rs10
-rw-r--r--src/libsyntax/parse/mod.rs15
-rw-r--r--src/libsyntax/parse/obsolete.rs7
-rw-r--r--src/libsyntax/parse/parser.rs196
-rw-r--r--src/libsyntax/parse/token.rs155
-rw-r--r--src/libsyntax/print/pp.rs11
-rw-r--r--src/libsyntax/print/pprust.rs18
-rw-r--r--src/libsyntax/syntax.rc2
-rw-r--r--src/libsyntax/visit.rs52
m---------src/llvm0
-rw-r--r--src/rt/arch/arm/_context.S2
-rw-r--r--src/rt/arch/arm/gpr.cpp1
-rw-r--r--src/rt/arch/arm/gpr.h1
-rw-r--r--src/rt/arch/arm/morestack.S4
-rw-r--r--src/rt/arch/arm/record_sp.S1
-rw-r--r--src/rt/arch/arm/regs.h2
-rw-r--r--src/rt/arch/i386/_context.S2
-rw-r--r--src/rt/arch/i386/gpr.cpp1
-rw-r--r--src/rt/arch/i386/gpr.h1
-rw-r--r--src/rt/arch/i386/morestack.S3
-rw-r--r--src/rt/arch/mips/gpr.h1
-rw-r--r--src/rt/arch/x86_64/_context.S1
-rw-r--r--src/rt/arch/x86_64/gpr.cpp1
-rw-r--r--src/rt/arch/x86_64/gpr.h1
-rw-r--r--src/rt/arch/x86_64/regs.h2
-rw-r--r--src/rt/boxed_region.cpp14
-rw-r--r--src/rt/boxed_region.h6
-rw-r--r--src/rt/isaac/rand.h2
-rw-r--r--src/rt/memory_region.cpp15
-rw-r--r--src/rt/memory_region.h5
-rw-r--r--src/rt/rust_abi.cpp1
-rw-r--r--src/rt/rust_abi.h1
-rw-r--r--src/rt/rust_android_dummy.cpp18
-rw-r--r--src/rt/rust_android_dummy.h24
-rw-r--r--src/rt/rust_builtin.cpp57
-rw-r--r--src/rt/rust_debug.cpp1
-rw-r--r--src/rt/rust_debug.h1
-rw-r--r--src/rt/rust_gpr_base.h1
-rw-r--r--src/rt/rust_run_program.cpp200
-rw-r--r--src/rt/rust_sched_loop.cpp2
-rw-r--r--src/rt/rust_task.cpp2
-rw-r--r--src/rt/rust_task.h4
-rw-r--r--src/rt/rust_test_helpers.cpp11
-rw-r--r--src/rt/rust_upcall.cpp16
-rw-r--r--src/rt/rustrt.def.in14
-rw-r--r--src/rustllvm/README1
-rw-r--r--src/rustllvm/RustWrapper.cpp22
-rw-r--r--src/snapshots.txt10
-rw-r--r--src/test/auxiliary/anon_trait_static_method_lib.rs1
-rw-r--r--src/test/auxiliary/cci_class_2.rs1
-rw-r--r--src/test/auxiliary/cci_class_6.rs1
-rw-r--r--src/test/auxiliary/cci_class_cast.rs2
-rw-r--r--src/test/auxiliary/cci_no_inline_lib.rs1
-rw-r--r--src/test/auxiliary/explicit_self_xcrate.rs2
-rw-r--r--src/test/auxiliary/extern_mod_ordering_lib.rs1
-rw-r--r--src/test/auxiliary/foreign_lib.rs1
-rw-r--r--src/test/auxiliary/impl_privacy_xc_1.rs1
-rw-r--r--src/test/auxiliary/impl_privacy_xc_2.rs2
-rw-r--r--src/test/auxiliary/issue-2196-c.rc16
-rw-r--r--src/test/auxiliary/issue-2196-d.rs0
-rw-r--r--src/test/auxiliary/issue-2414-a.rs1
-rw-r--r--src/test/auxiliary/issue-2414-b.rs1
-rw-r--r--src/test/auxiliary/issue-2526.rs1
-rw-r--r--src/test/auxiliary/issue2378a.rs11
-rw-r--r--src/test/auxiliary/issue2378b.rs14
-rw-r--r--src/test/auxiliary/issue_2316_b.rs2
-rw-r--r--src/test/auxiliary/issue_3136_a.rs5
-rw-r--r--src/test/auxiliary/issue_3882.rs2
-rw-r--r--src/test/auxiliary/moves_based_on_type_lib.rs1
-rw-r--r--src/test/auxiliary/newtype_struct_xc.rs1
-rw-r--r--src/test/auxiliary/pub_use_mods_xcrate.rs1
-rw-r--r--src/test/auxiliary/static_fn_inline_xc_aux.rs1
-rw-r--r--src/test/auxiliary/struct_destructuring_cross_crate.rs1
-rw-r--r--src/test/auxiliary/trait_inheritance_auto_xc_2_aux.rs2
-rw-r--r--src/test/auxiliary/trait_inheritance_overloading_xc.rs1
-rw-r--r--src/test/auxiliary/xc_private_method_lib.rs1
-rw-r--r--src/test/bench/msgsend-pipes-shared.rs2
-rw-r--r--src/test/bench/msgsend-pipes.rs2
-rw-r--r--src/test/bench/msgsend-ring-mutex-arcs.rs2
-rw-r--r--src/test/bench/msgsend-ring-pipes.rs2
-rw-r--r--src/test/bench/msgsend-ring-rw-arcs.rs2
-rw-r--r--src/test/bench/pingpong.rs2
-rw-r--r--src/test/bench/shootout-binarytrees.rs23
-rw-r--r--src/test/bench/shootout-chameneos-redux.rs1
-rw-r--r--src/test/bench/shootout-fannkuch-redux.rs1
-rw-r--r--src/test/bench/shootout-fasta-redux.rs1
-rw-r--r--src/test/bench/shootout-k-nucleotide-pipes.rs1
-rw-r--r--src/test/bench/shootout-k-nucleotide.rs3
-rw-r--r--src/test/bench/shootout-mandelbrot.rs1
-rw-r--r--src/test/bench/shootout-pidigits.rs1
-rw-r--r--src/test/bench/shootout-reverse-complement.rs1
-rw-r--r--src/test/bench/sudoku.rs1
-rw-r--r--src/test/compile-fail/alt-tag-nullary.rs1
-rw-r--r--src/test/compile-fail/alt-tag-unary.rs1
-rw-r--r--src/test/compile-fail/alt-vec-mismatch-2.rs2
-rw-r--r--src/test/compile-fail/alt-vec-mismatch.rs2
-rw-r--r--src/test/compile-fail/bogus-tag.rs1
-rw-r--r--src/test/compile-fail/borrowck-assign-comp-idx.rs1
-rw-r--r--src/test/compile-fail/borrowck-assign-comp.rs1
-rw-r--r--src/test/compile-fail/borrowck-auto-mut-ref-to-immut-var.rs1
-rw-r--r--src/test/compile-fail/borrowck-call-method-from-mut-aliasable.rs1
-rw-r--r--src/test/compile-fail/borrowck-loan-local-as-both-mut-and-imm.rs2
-rw-r--r--src/test/compile-fail/borrowck-loan-rcvr-overloaded-op.rs1
-rw-r--r--src/test/compile-fail/borrowck-loan-rcvr.rs1
-rw-r--r--src/test/compile-fail/borrowck-mut-boxed-vec.rs1
-rw-r--r--src/test/compile-fail/borrowck-ref-into-rvalue.rs1
-rw-r--r--src/test/compile-fail/borrowck-vec-pattern-loan-from-mut.rs1
-rw-r--r--src/test/compile-fail/borrowck-vec-pattern-nesting.rs1
-rw-r--r--src/test/compile-fail/borrowck-wg-borrow-mut-to-imm-fail-2.rs1
-rw-r--r--src/test/compile-fail/borrowck-wg-borrow-mut-to-imm-fail-3.rs1
-rw-r--r--src/test/compile-fail/borrowck-wg-borrow-mut-to-imm-fail.rs1
-rw-r--r--src/test/compile-fail/borrowck-wg-move-base-2.rs2
-rw-r--r--src/test/compile-fail/by-move-pattern-binding.rs1
-rw-r--r--src/test/compile-fail/dead-code-ret.rs1
-rw-r--r--src/test/compile-fail/does-nothing.rs1
-rw-r--r--src/test/compile-fail/drop-on-non-struct.rs2
-rw-r--r--src/test/compile-fail/eval-enum.rs2
-rw-r--r--src/test/compile-fail/explicit-call-to-dtor.rs1
-rw-r--r--src/test/compile-fail/explicit-call-to-supertrait-dtor.rs2
-rw-r--r--src/test/compile-fail/float-literal-inference-restrictions.rs1
-rw-r--r--src/test/compile-fail/foreign-unsafe-fn-called.rs1
-rw-r--r--src/test/compile-fail/foreign-unsafe-fn.rs2
-rw-r--r--src/test/compile-fail/issue-1451.rs1
-rw-r--r--src/test/compile-fail/issue-2951.rs1
-rw-r--r--src/test/compile-fail/issue-3044.rs1
-rw-r--r--src/test/compile-fail/issue-3096-2.rs2
-rw-r--r--src/test/compile-fail/issue-3991.rs4
-rw-r--r--src/test/compile-fail/issue-4265.rs4
-rw-r--r--src/test/compile-fail/issue-4366.rs1
-rw-r--r--src/test/compile-fail/issue-4968.rs1
-rw-r--r--src/test/compile-fail/issue-5100.rs44
-rw-r--r--src/test/compile-fail/issue-5358-1.rs (renamed from src/test/run-pass/issue-1466.rs)13
-rw-r--r--src/test/compile-fail/issue-5358.rs (renamed from src/test/auxiliary/issue-2196-b.rs)15
-rw-r--r--src/test/compile-fail/issue-5927.rs (renamed from src/test/auxiliary/issue-2196-a.rs)13
-rw-r--r--src/test/compile-fail/kindck-destructor-owned.rs1
-rw-r--r--src/test/compile-fail/lint-default-methods.rs1
-rw-r--r--src/test/compile-fail/lint-type-limits.rs1
-rw-r--r--src/test/compile-fail/liveness-if-no-else.rs4
-rw-r--r--src/test/compile-fail/liveness-return.rs4
-rw-r--r--src/test/compile-fail/liveness-uninit-after-item.rs1
-rw-r--r--src/test/compile-fail/liveness-uninit.rs4
-rw-r--r--src/test/compile-fail/macro-with-seps-err-msg.rs2
-rw-r--r--src/test/compile-fail/missing-derivable-attr.rs1
-rw-r--r--src/test/compile-fail/missing-return.rs1
-rw-r--r--src/test/compile-fail/moves-based-on-type-block-bad.rs1
-rw-r--r--src/test/compile-fail/moves-based-on-type-capture-clause-bad.rs1
-rw-r--r--src/test/compile-fail/moves-based-on-type-cyclic-types-issue-4821.rs1
-rw-r--r--src/test/compile-fail/no-capture-arc.rs2
-rw-r--r--src/test/compile-fail/noexporttypeexe.rs1
-rw-r--r--src/test/compile-fail/non-exhaustive-match-nested.rs1
-rw-r--r--src/test/compile-fail/once-fn-subtyping.rs1
-rw-r--r--src/test/compile-fail/private-impl-method.rs1
-rw-r--r--src/test/compile-fail/private-item-simple.rs1
-rw-r--r--src/test/compile-fail/private-method-inherited.rs1
-rw-r--r--src/test/compile-fail/private-struct-field-ctor.rs1
-rw-r--r--src/test/compile-fail/private-struct-field-pattern.rs1
-rw-r--r--src/test/compile-fail/qquote-1.rs1
-rw-r--r--src/test/compile-fail/qquote-2.rs1
-rw-r--r--src/test/compile-fail/refutable-pattern-in-fn-arg.rs1
-rw-r--r--src/test/compile-fail/regions-addr-of-self.rs1
-rw-r--r--src/test/compile-fail/regions-infer-borrow-scope-too-big.rs1
-rw-r--r--src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs4
-rw-r--r--src/test/compile-fail/regions-ret.rs1
-rw-r--r--src/test/compile-fail/repeat-to-run-dtor-twice.rs1
-rw-r--r--src/test/compile-fail/static-method-privacy.rs1
-rw-r--r--src/test/compile-fail/static-region-bound.rs1
-rw-r--r--src/test/compile-fail/struct-like-enum-nonexhaustive.rs2
-rw-r--r--src/test/compile-fail/super-at-top-level.rs2
-rw-r--r--src/test/compile-fail/trait-impl-method-mismatch.rs4
-rw-r--r--src/test/compile-fail/trait-inheritance-missing-requirement.rs1
-rw-r--r--src/test/compile-fail/tuple-struct-nonexhaustive.rs2
-rw-r--r--src/test/compile-fail/tutorial-suffix-inference-test.rs4
-rw-r--r--src/test/compile-fail/uninhabited-enum-cast.rs7
-rw-r--r--src/test/compile-fail/unique-object-noncopyable.rs1
-rw-r--r--src/test/compile-fail/use-after-move-based-on-type.rs1
-rw-r--r--src/test/compile-fail/use-after-move-self-based-on-type.rs1
-rw-r--r--src/test/compile-fail/use-after-move-self.rs1
-rw-r--r--src/test/compile-fail/view-items-at-top.rs1
-rw-r--r--src/test/compile-fail/while-type-error.rs1
-rw-r--r--src/test/compile-fail/xc-private-method.rs1
-rw-r--r--src/test/pretty/doc-comments.rs2
-rw-r--r--src/test/run-fail/assert-as-macro.rs1
-rw-r--r--src/test/run-fail/borrowck-wg-fail-3.rs1
-rw-r--r--src/test/run-fail/borrowck-wg-fail.rs1
-rw-r--r--src/test/run-fail/divide-by-zero.rs2
-rw-r--r--src/test/run-fail/unwind-resource-fail3.rs2
-rw-r--r--src/test/run-pass-fulldeps/qquote.rs1
-rw-r--r--src/test/run-pass-fulldeps/quote-tokens.rs1
-rw-r--r--src/test/run-pass/anon-trait-static-method.rs1
-rw-r--r--src/test/run-pass/anon_trait_static_method_exe.rs3
-rw-r--r--src/test/run-pass/auto-encode.rs7
-rw-r--r--src/test/run-pass/auto-ref-newtype.rs1
-rw-r--r--src/test/run-pass/auto-ref.rs1
-rw-r--r--src/test/run-pass/autoderef-and-borrow-method-receiver.rs1
-rw-r--r--src/test/run-pass/bare-static-string.rs1
-rw-r--r--src/test/run-pass/binops.rs2
-rw-r--r--src/test/run-pass/block-arg-in-parentheses.rs1
-rw-r--r--src/test/run-pass/borrow-by-val-method-receiver.rs1
-rw-r--r--src/test/run-pass/borrowck-wg-simple.rs1
-rw-r--r--src/test/run-pass/boxed-trait-with-vstore.rs1
-rw-r--r--src/test/run-pass/break.rs6
-rw-r--r--src/test/run-pass/class-cast-to-trait-cross-crate-2.rs1
-rw-r--r--src/test/run-pass/class-impl-parameterized-trait.rs2
-rw-r--r--src/test/run-pass/cleanup-copy-mode.rs1
-rw-r--r--src/test/run-pass/clone-with-exterior.rs2
-rw-r--r--src/test/run-pass/conditional-compile.rs2
-rw-r--r--src/test/run-pass/const-enum-vec-index.rs2
-rw-r--r--src/test/run-pass/const-enum-vec-ptr.rs2
-rw-r--r--src/test/run-pass/const-enum-vector.rs2
-rw-r--r--src/test/run-pass/const-expr-in-fixed-length-vec.rs2
-rw-r--r--src/test/run-pass/const-expr-in-vec-repeat.rs2
-rw-r--r--src/test/run-pass/const-tuple-struct.rs1
-rw-r--r--src/test/run-pass/const-unit-struct.rs1
-rw-r--r--src/test/run-pass/const-vec-syntax.rs1
-rw-r--r--src/test/run-pass/consts-in-patterns.rs1
-rw-r--r--src/test/run-pass/cycle-collection.rs1
-rw-r--r--src/test/run-pass/default-method-simple.rs1
-rw-r--r--src/test/run-pass/deriving-clone-enum.rs1
-rw-r--r--src/test/run-pass/deriving-clone-generic-enum.rs1
-rw-r--r--src/test/run-pass/deriving-clone-generic-struct.rs1
-rw-r--r--src/test/run-pass/deriving-clone-generic-tuple-struct.rs1
-rw-r--r--src/test/run-pass/deriving-clone-tuple-struct.rs1
-rw-r--r--src/test/run-pass/deriving-via-extension-c-enum.rs1
-rw-r--r--src/test/run-pass/deriving-via-extension-enum.rs1
-rw-r--r--src/test/run-pass/deriving-via-extension-iter-bytes-enum.rs1
-rw-r--r--src/test/run-pass/deriving-via-extension-iter-bytes-struct.rs2
-rw-r--r--src/test/run-pass/deriving-via-extension-struct-like-enum-variant.rs1
-rw-r--r--src/test/run-pass/deriving-via-extension-struct.rs1
-rw-r--r--src/test/run-pass/deriving-via-extension-type-params.rs1
-rw-r--r--src/test/run-pass/drop-trait-generic.rs1
-rw-r--r--src/test/run-pass/drop-trait.rs1
-rw-r--r--src/test/run-pass/enum-discrim-range-overflow.rs24
-rw-r--r--src/test/run-pass/enum-disr-val-pretty.rs1
-rw-r--r--src/test/run-pass/enum-export-inheritance.rs1
-rw-r--r--src/test/run-pass/enum-nullable-simplifycfg-misopt.rs (renamed from src/libcore/rt/io/net/mod.rs)31
-rw-r--r--src/test/run-pass/explicit-self-generic.rs1
-rw-r--r--src/test/run-pass/explicit-self-objects-box.rs2
-rw-r--r--src/test/run-pass/explicit-self-objects-simple.rs2
-rw-r--r--src/test/run-pass/explicit-self-objects-uniq.rs2
-rw-r--r--src/test/run-pass/explicit_self_xcrate_exe.rs1
-rw-r--r--src/test/run-pass/expr-repeat-vstore.rs1
-rw-r--r--src/test/run-pass/extern-mod-abi.rs1
-rw-r--r--src/test/run-pass/extern-mod-ordering-exe.rs1
-rw-r--r--src/test/run-pass/extern-mod-syntax.rs1
-rw-r--r--src/test/run-pass/extern-pass-TwoU16s.rs1
-rw-r--r--src/test/run-pass/extern-pass-TwoU32s.rs1
-rw-r--r--src/test/run-pass/extern-pass-TwoU64s-ref.rs1
-rw-r--r--src/test/run-pass/extern-pass-TwoU64s.rs1
-rw-r--r--src/test/run-pass/extern-pass-TwoU8s.rs1
-rw-r--r--src/test/run-pass/extern-pass-char.rs1
-rw-r--r--src/test/run-pass/extern-pass-double.rs1
-rw-r--r--src/test/run-pass/extern-pass-u32.rs1
-rw-r--r--src/test/run-pass/extern-pass-u64.rs1
-rw-r--r--src/test/run-pass/extern-pub.rs2
-rw-r--r--src/test/run-pass/fat-arrow-alt.rs1
-rw-r--r--src/test/run-pass/fixed_length_copy.rs2
-rw-r--r--src/test/run-pass/float-literal-inference.rs1
-rw-r--r--src/test/run-pass/fn-pattern-expected-type-2.rs1
-rw-r--r--src/test/run-pass/fn-pattern-expected-type.rs1
-rw-r--r--src/test/run-pass/foreign-mod-unused-const.rs1
-rw-r--r--src/test/run-pass/functional-struct-update.rs1
-rw-r--r--src/test/run-pass/generic-ivec-leak.rs1
-rw-r--r--src/test/run-pass/generic-ivec.rs1
-rw-r--r--src/test/run-pass/generic-newtype-struct.rs1
-rw-r--r--src/test/run-pass/generic-object.rs1
-rw-r--r--src/test/run-pass/global-scope.rs1
-rw-r--r--src/test/run-pass/impl-privacy-xc-1.rs1
-rw-r--r--src/test/run-pass/impl-privacy-xc-2.rs1
-rw-r--r--src/test/run-pass/infinite-loops.rs4
-rw-r--r--src/test/run-pass/instantiable.rs1
-rw-r--r--src/test/run-pass/int-conversion-coherence.rs1
-rw-r--r--src/test/run-pass/intrinsics-integer.rs2
-rw-r--r--src/test/run-pass/intrinsics-math.rs4
-rw-r--r--src/test/run-pass/issue-1516.rs1
-rw-r--r--src/test/run-pass/issue-1989.rs33
-rw-r--r--src/test/run-pass/issue-2185.rs32
-rw-r--r--src/test/run-pass/issue-2196.rs19
-rw-r--r--src/test/run-pass/issue-2216.rs2
-rw-r--r--src/test/run-pass/issue-2526-a.rs1
-rw-r--r--src/test/run-pass/issue-2734.rs4
-rw-r--r--src/test/run-pass/issue-2869.rs24
-rw-r--r--src/test/run-pass/issue-2904.rs2
-rw-r--r--src/test/run-pass/issue-3176.rs4
-rw-r--r--src/test/run-pass/issue-3250.rs2
-rw-r--r--src/test/run-pass/issue-3429.rs (renamed from src/test/run-pass/issue-1895.rs)1
-rw-r--r--src/test/run-pass/issue-3461.rs2
-rw-r--r--src/test/run-pass/issue-3480.rs26
-rw-r--r--src/test/run-pass/issue-3556.rs8
-rw-r--r--src/test/run-pass/issue-3563-3.rs5
-rw-r--r--src/test/run-pass/issue-3609.rs1
-rw-r--r--src/test/run-pass/issue-3860.rs2
-rw-r--r--src/test/run-pass/issue-3895.rs2
-rw-r--r--src/test/run-pass/issue-3979-2.rs1
-rw-r--r--src/test/run-pass/issue-3979-generics.rs2
-rw-r--r--src/test/run-pass/issue-4036.rs3
-rw-r--r--src/test/run-pass/issue-4241.rs2
-rw-r--r--src/test/run-pass/issue-4875.rs1
-rw-r--r--src/test/run-pass/issue-6117.rs (renamed from src/test/auxiliary/issue-2196-c.rs)12
-rw-r--r--src/test/run-pass/issue-868.rs1
-rw-r--r--src/test/run-pass/issue2378c.rs12
-rw-r--r--src/test/run-pass/issue_3136_b.rs1
-rw-r--r--src/test/run-pass/item-attributes.rs10
-rw-r--r--src/test/run-pass/ivec-add.rs1
-rw-r--r--src/test/run-pass/ivec-pass-by-value.rs1
-rw-r--r--src/test/run-pass/labeled-break.rs1
-rw-r--r--src/test/run-pass/let-assignability.rs1
-rw-r--r--src/test/run-pass/liveness-assign-imm-local-after-loop.rs2
-rw-r--r--src/test/run-pass/log-linearized.rs1
-rw-r--r--src/test/run-pass/max-min-classes.rs1
-rw-r--r--src/test/run-pass/mlist-cycle.rs14
-rw-r--r--src/test/run-pass/module-qualified-struct-destructure.rs1
-rw-r--r--src/test/run-pass/move-self.rs1
-rw-r--r--src/test/run-pass/moves-based-on-type-capture-clause.rs1
-rw-r--r--src/test/run-pass/multiple-trait-bounds.rs1
-rw-r--r--src/test/run-pass/mut-vstore-expr.rs1
-rw-r--r--src/test/run-pass/nested-class.rs22
-rw-r--r--src/test/run-pass/new-impl-syntax.rs1
-rw-r--r--src/test/run-pass/new-import-syntax.rs1
-rw-r--r--src/test/run-pass/new-style-constants.rs1
-rw-r--r--src/test/run-pass/new-style-fixed-length-vec.rs3
-rw-r--r--src/test/run-pass/new-vstore-mut-box-syntax.rs1
-rw-r--r--src/test/run-pass/newtype-struct-drop-run.rs (renamed from src/test/run-pass/tstate-loop-break.rs)25
-rw-r--r--src/test/run-pass/newtype-struct-with-dtor.rs2
-rw-r--r--src/test/run-pass/newtype-struct-xc-2.rs1
-rw-r--r--src/test/run-pass/newtype-struct-xc.rs1
-rw-r--r--src/test/run-pass/nullable-pointer-iotareduction.rs2
-rw-r--r--src/test/run-pass/one-tuple.rs1
-rw-r--r--src/test/run-pass/pattern-in-closure.rs1
-rw-r--r--src/test/run-pass/pipe-detect-term.rs4
-rw-r--r--src/test/run-pass/pipe-pingpong-bounded.rs2
-rw-r--r--src/test/run-pass/pipe-pingpong-proto.rs2
-rw-r--r--src/test/run-pass/pipe-select.rs6
-rw-r--r--src/test/run-pass/pipe-sleep.rs2
-rw-r--r--src/test/run-pass/placement-new-arena.rs3
-rw-r--r--src/test/run-pass/preempt.rs8
-rw-r--r--src/test/run-pass/pub-use-xcrate.rs1
-rw-r--r--src/test/run-pass/pub_use_mods_xcrate_exe.rs1
-rw-r--r--src/test/run-pass/reexport-star.rs1
-rw-r--r--src/test/run-pass/regions-addr-of-interior-of-unique-box.rs1
-rw-r--r--src/test/run-pass/regions-addr-of-ret.rs1
-rw-r--r--src/test/run-pass/regions-fn-subtyping-2.rs8
-rw-r--r--src/test/run-pass/regions-infer-borrow-scope-addr-of.rs16
-rw-r--r--src/test/run-pass/regions-infer-borrow-scope-view.rs1
-rw-r--r--src/test/run-pass/regions-infer-borrow-scope-within-loop-ok.rs2
-rw-r--r--src/test/run-pass/regions-infer-borrow-scope.rs1
-rw-r--r--src/test/run-pass/regions-mock-trans-impls.rs29
-rw-r--r--src/test/run-pass/regions-mock-trans.rs1
-rw-r--r--src/test/run-pass/regions-self-impls.rs1
-rw-r--r--src/test/run-pass/regions-self-in-enums.rs1
-rw-r--r--src/test/run-pass/regions-simple.rs2
-rw-r--r--src/test/run-pass/repeated-vector-syntax.rs1
-rw-r--r--src/test/run-pass/resource-cycle.rs4
-rw-r--r--src/test/run-pass/resource-cycle3.rs4
-rw-r--r--src/test/run-pass/self-type-param.rs1
-rw-r--r--src/test/run-pass/spawn.rs8
-rw-r--r--src/test/run-pass/spawn2.rs8
-rw-r--r--src/test/run-pass/static-methods-in-traits.rs37
-rw-r--r--src/test/run-pass/struct-deref.rs1
-rw-r--r--src/test/run-pass/struct-field-assignability.rs1
-rw-r--r--src/test/run-pass/struct-like-variant-construct.rs1
-rw-r--r--src/test/run-pass/struct-like-variant-match.rs1
-rw-r--r--src/test/run-pass/struct-pattern-matching.rs3
-rw-r--r--src/test/run-pass/super.rs1
-rw-r--r--src/test/run-pass/tag-align-dyn-u64.rs14
-rw-r--r--src/test/run-pass/tag-align-dyn-variants.rs62
-rw-r--r--src/test/run-pass/tag-align-shape.rs16
-rw-r--r--src/test/run-pass/tag-align-u64.rs14
-rw-r--r--src/test/run-pass/tag-disr-val-shape.rs1
-rw-r--r--src/test/run-pass/tag-variant-disr-val.rs2
-rw-r--r--src/test/run-pass/task-killjoin-rsrc.rs8
-rw-r--r--src/test/run-pass/task-killjoin.rs8
-rw-r--r--src/test/run-pass/threads.rs1
-rw-r--r--src/test/run-pass/trait-composition-trivial.rs2
-rw-r--r--src/test/run-pass/trait-inheritance-auto-xc-2.rs1
-rw-r--r--src/test/run-pass/trait-inheritance-auto-xc.rs1
-rw-r--r--src/test/run-pass/trait-inheritance-auto.rs1
-rw-r--r--src/test/run-pass/trait-inheritance-call-bound-inherited.rs1
-rw-r--r--src/test/run-pass/trait-inheritance-call-bound-inherited2.rs1
-rw-r--r--src/test/run-pass/trait-inheritance-cast-without-call-to-supertrait.rs1
-rw-r--r--src/test/run-pass/trait-inheritance-cast.rs1
-rw-r--r--src/test/run-pass/trait-inheritance-cross-trait-call-xc.rs1
-rw-r--r--src/test/run-pass/trait-inheritance-cross-trait-call.rs1
-rw-r--r--src/test/run-pass/trait-inheritance-overloading-simple.rs1
-rw-r--r--src/test/run-pass/trait-inheritance-overloading-xc-exe.rs1
-rw-r--r--src/test/run-pass/trait-inheritance-overloading.rs1
-rw-r--r--src/test/run-pass/trait-inheritance-self.rs1
-rw-r--r--src/test/run-pass/trait-inheritance-simple.rs1
-rw-r--r--src/test/run-pass/trait-inheritance-subst.rs1
-rw-r--r--src/test/run-pass/trait-inheritance-subst2.rs1
-rw-r--r--src/test/run-pass/trait-inheritance2.rs1
-rw-r--r--src/test/run-pass/trait-region-pointer-simple.rs1
-rw-r--r--src/test/run-pass/trait-static-method-overwriting.rs6
-rw-r--r--src/test/run-pass/traits.rs1
-rw-r--r--src/test/run-pass/tuple-struct-construct.rs1
-rw-r--r--src/test/run-pass/tuple-struct-destructuring.rs1
-rw-r--r--src/test/run-pass/tuple-struct-matching.rs1
-rw-r--r--src/test/run-pass/tuple-struct-trivial.rs1
-rw-r--r--src/test/run-pass/type-sizes.rs25
-rw-r--r--src/test/run-pass/typeclasses-eq-example-static.rs2
-rw-r--r--src/test/run-pass/typeclasses-eq-example.rs2
-rw-r--r--src/test/run-pass/unique-object.rs1
-rw-r--r--src/test/run-pass/unit-like-struct.rs1
-rw-r--r--src/test/run-pass/unsafe-pointer-assignability.rs3
-rw-r--r--src/test/run-pass/vec-fixed-length.rs1
661 files changed, 7066 insertions, 5559 deletions
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 00000000000..52370e4a509
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,9 @@
+[attr]rust text eol=lf whitespace=tab-in-indent,trailing-space,tabwidth=4
+
+* text=auto
+*.cpp rust
+*.h rust
+*.rs rust
+src/rt/msvc/* -whitespace
+src/rt/vg/* -whitespace
+src/rt/linenoise/* -whitespace
diff --git a/COPYRIGHT b/COPYRIGHT
index 2315c6fe3cb..ffbfadaa339 100644
--- a/COPYRIGHT
+++ b/COPYRIGHT
@@ -367,4 +367,3 @@ their own copyright notices and license terms:
   has chosen for the collective work, enumerated at the top
   of this file. The only difference is the retention of
   copyright itself, held by the contributor.
-
diff --git a/Makefile.in b/Makefile.in
index 111ad1369de..d531b9879a9 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -241,7 +241,7 @@ $(foreach target,$(CFG_TARGET_TRIPLES),\
 
 CORELIB_CRATE := $(S)src/libcore/core.rc
 CORELIB_INPUTS := $(wildcard $(addprefix $(S)src/libcore/,        \
-                                           core.rc *.rs */*.rs */*/*rs))
+                                           core.rc *.rs */*.rs */*/*rs */*/*/*rs))
 
 ######################################################################
 # Standard library variables
diff --git a/RELEASES.txt b/RELEASES.txt
index 13e4e0c2039..fb2bbb45e7c 100644
--- a/RELEASES.txt
+++ b/RELEASES.txt
@@ -250,7 +250,7 @@ Version 0.3  (July 2012)
       * Slices and fixed-size, interior-allocated vectors
       * #!-comments for lang versioning, shell execution
       * Destructors and iface implementation for classes;
-      	type-parameterized classes and class methods
+        type-parameterized classes and class methods
       * 'const' type kind for types that can be used to implement
         shared-memory concurrency patterns
 
@@ -261,7 +261,7 @@ Version 0.3  (July 2012)
                  'crust', 'native' (now 'extern'), 'cont' (now 'again')
 
       * Constructs: do-while loops ('do' repurposed), fn binding,
-      	            resources (replaced by destructors)
+                    resources (replaced by destructors)
 
    * Compiler reorganization
       * Syntax-layer of compiler split into separate crate
@@ -276,7 +276,7 @@ Version 0.3  (July 2012)
       * Extensive work on libuv interface
       * Much vector code moved to libraries
       * Syntax extensions: #line, #col, #file, #mod, #stringify,
-      	#include, #include_str, #include_bin
+        #include, #include_str, #include_bin
 
    * Tool improvements
       * Cargo automatically resolves dependencies
diff --git a/doc/README b/doc/README
index 505b5383dcd..c3bb28a9e85 100644
--- a/doc/README
+++ b/doc/README
@@ -1,6 +1,6 @@
 The markdown docs are only generated by make when node is installed (use
-`make doc`). If you don't have node installed you can generate them yourself. 
-Unfortunately there's no real standard for markdown and all the tools work 
+`make doc`). If you don't have node installed you can generate them yourself.
+Unfortunately there's no real standard for markdown and all the tools work
 differently. pandoc is one that seems to work well.
 
 To generate an html version of a doc do something like:
@@ -10,4 +10,4 @@ The syntax for pandoc flavored markdown can be found at:
 http://johnmacfarlane.net/pandoc/README.html#pandocs-markdown
 
 A nice quick reference (for non-pandoc markdown) is at:
-http://kramdown.rubyforge.org/quickref.html
\ No newline at end of file
+http://kramdown.rubyforge.org/quickref.html
diff --git a/doc/rust.md b/doc/rust.md
index 136c7ee9da3..ac7125be424 100644
--- a/doc/rust.md
+++ b/doc/rust.md
@@ -1467,8 +1467,8 @@ A complete list of the built-in language items follows:
   : Elements can be subtracted.
 `mul`
   : Elements can be multiplied.
-`quot`
-  : Elements have a quotient operation.
+`div`
+  : Elements have a division operation.
 `rem`
   : Elements have a remainder operation.
 `neg`
@@ -1857,7 +1857,7 @@ The default meaning of the operators on standard types is given here.
     Calls the `mul` method on the `core::ops::Mul` trait.
 `/`
   : Quotient.
-    Calls the `quot` method on the `core::ops::Quot` trait.
+    Calls the `div` method on the `core::ops::Div` trait.
 `%`
   : Remainder.
     Calls the `rem` method on the `core::ops::Rem` trait.
@@ -2393,7 +2393,7 @@ variables in the arm's block, and control enters the block.
 An example of an `match` expression:
 
 
-~~~~ {.xfail-test}
+~~~~
 # fn process_pair(a: int, b: int) { }
 # fn process_ten() { }
 
@@ -3351,4 +3351,3 @@ Additional specific influences can be seen from the following languages:
 * The typeclass system of Haskell.
 * The lexical identifier rule of Python.
 * The block syntax of Ruby.
-
diff --git a/doc/tutorial-ffi.md b/doc/tutorial-ffi.md
index 127f8158923..b806df5dd20 100644
--- a/doc/tutorial-ffi.md
+++ b/doc/tutorial-ffi.md
@@ -150,11 +150,7 @@ wrapping `malloc` and `free`:
 
 ~~~~
 use core::libc::{c_void, size_t, malloc, free};
-
-#[abi = "rust-intrinsic"]
-extern "rust-intrinsic" mod rusti {
-    fn init<T>() -> T;
-}
+use core::unstable::intrinsics;
 
 // a wrapper around the handle returned by the foreign code
 pub struct Unique<T> {
@@ -166,7 +162,8 @@ pub impl<'self, T: Owned> Unique<T> {
         unsafe {
             let ptr = malloc(core::sys::size_of::<T>() as size_t) as *mut T;
             assert!(!ptr::is_null(ptr));
-            *ptr = value;
+            // `*ptr` is uninitialized, and `*ptr = value` would attempt to destroy it
+            intrinsics::move_val_init(&mut *ptr, value);
             Unique{ptr: ptr}
         }
     }
@@ -186,7 +183,7 @@ pub impl<'self, T: Owned> Unique<T> {
 impl<T: Owned> Drop for Unique<T> {
     fn finalize(&self) {
         unsafe {
-            let mut x = rusti::init(); // dummy value to swap in
+            let mut x = intrinsics::init(); // dummy value to swap in
             x <-> *self.ptr; // moving the object out is needed to call the destructor
             free(self.ptr as *c_void)
         }
diff --git a/doc/tutorial-macros.md b/doc/tutorial-macros.md
index 24e9f4abc38..63fa7e06bae 100644
--- a/doc/tutorial-macros.md
+++ b/doc/tutorial-macros.md
@@ -402,4 +402,3 @@ tricky. Invoking the `log_syntax!` macro can help elucidate intermediate
 states, invoking `trace_macros!(true)` will automatically print those
 intermediate states out, and passing the flag `--pretty expanded` as a
 command-line argument to the compiler will show the result of expansion.
-
diff --git a/doc/tutorial-tasks.md b/doc/tutorial-tasks.md
index bed69674830..053d9e6d988 100644
--- a/doc/tutorial-tasks.md
+++ b/doc/tutorial-tasks.md
@@ -511,4 +511,3 @@ The parent task first calls `DuplexStream` to create a pair of bidirectional
 endpoints. It then uses `task::spawn` to create the child task, which captures
 one end of the communication channel.  As a result, both parent and child can
 send and receive data to and from the other.
-
diff --git a/doc/tutorial.md b/doc/tutorial.md
index 07eb3bc7681..90ae41affc9 100644
--- a/doc/tutorial.md
+++ b/doc/tutorial.md
@@ -1006,9 +1006,9 @@ let mut d = @mut 5; // mutable variable, mutable box
 d = @mut 15;
 ~~~~
 
-A mutable variable and an immutable variable can refer to the same box, given 
-that their types are compatible. Mutability of a box is a property of its type, 
-however, so for example a mutable handle to an immutable box cannot be 
+A mutable variable and an immutable variable can refer to the same box, given
+that their types are compatible. Mutability of a box is a property of its type,
+however, so for example a mutable handle to an immutable box cannot be
 assigned a reference to a mutable box.
 
 ~~~~
@@ -1041,7 +1041,7 @@ let y = x.clone(); // y is a newly allocated box
 let z = x; // no new memory allocated, x can no longer be used
 ~~~~
 
-Since in owned boxes mutability is a property of the owner, not the 
+Since in owned boxes mutability is a property of the owner, not the
 box, mutable boxes may become immutable when they are moved, and vice-versa.
 
 ~~~~
diff --git a/doc/version_info.html.template b/doc/version_info.html.template
index 9376b29bcdf..aa44097a337 100644
--- a/doc/version_info.html.template
+++ b/doc/version_info.html.template
@@ -7,4 +7,3 @@
   </center>
 
 </div>
-
diff --git a/mk/clean.mk b/mk/clean.mk
index 30897eea457..660793b1c34 100644
--- a/mk/clean.mk
+++ b/mk/clean.mk
@@ -48,7 +48,7 @@ clean-misc:
 	$(Q)rm -f $(RUSTLLVM_LIB_OBJS) $(RUSTLLVM_OBJS_OBJS) $(RUSTLLVM_DEF)
 	$(Q)rm -Rf $(DOCS)
 	$(Q)rm -Rf $(GENERATED)
-	$(Q)rm -f tmp/*.log tmp/*.rc tmp/*.rs tmp/*.ok
+	$(Q)rm -f tmp/*
 	$(Q)rm -Rf rust-stage0-*.tar.bz2 $(PKG_NAME)-*.tar.gz dist
 	$(Q)rm -Rf $(foreach ext, \
                  html aux cp fn ky log pdf pg toc tp vr cps, \
diff --git a/mk/docs.mk b/mk/docs.mk
index 6873d433e95..f49c75d6acb 100644
--- a/mk/docs.mk
+++ b/mk/docs.mk
@@ -16,15 +16,8 @@ DOCS :=
 
 
 ######################################################################
-# Pandoc (reference-manual related)
+# Docs, from pandoc, rustdoc (which runs pandoc), and node
 ######################################################################
-ifeq ($(CFG_PANDOC),)
-  $(info cfg: no pandoc found, omitting doc/rust.pdf)
-else
-
-  ifeq ($(CFG_NODE),)
-    $(info cfg: no node found, omitting doc/tutorial.html)
-  else
 
 doc/rust.css: rust.css
 	@$(call E, cp: $@)
@@ -34,6 +27,18 @@ doc/manual.css: manual.css
 	@$(call E, cp: $@)
 	$(Q)cp -a $< $@ 2> /dev/null
 
+ifeq ($(CFG_PANDOC),)
+  $(info cfg: no pandoc found, omitting docs)
+  NO_DOCS = 1
+endif
+
+ifeq ($(CFG_NODE),)
+  $(info cfg: no node found, omitting docs)
+  NO_DOCS = 1
+endif
+
+ifneq ($(NO_DOCS),1)
+
 DOCS += doc/rust.html
 doc/rust.html: rust.md doc/version_info.html doc/rust.css doc/manual.css
 	@$(call E, pandoc: $@)
@@ -47,19 +52,8 @@ doc/rust.html: rust.md doc/version_info.html doc/rust.css doc/manual.css
          --css=manual.css \
 	     --include-before-body=doc/version_info.html \
          --output=$@
-  endif
 
-  ifeq ($(CFG_PDFLATEX),)
-    $(info cfg: no pdflatex found, omitting doc/rust.pdf)
-  else
-    ifeq ($(CFG_XETEX),)
-      $(info cfg: no xetex found, disabling doc/rust.pdf)
-    else
-      ifeq ($(CFG_LUATEX),)
-        $(info cfg: lacking luatex, disabling pdflatex)
-      else
-
-DOCS += doc/rust.pdf
+DOCS += doc/rust.tex
 doc/rust.tex: rust.md doc/version.md
 	@$(call E, pandoc: $@)
 	$(Q)$(CFG_NODE) $(S)doc/prep.js $< | \
@@ -70,17 +64,6 @@ doc/rust.tex: rust.md doc/version.md
          --from=markdown --to=latex \
          --output=$@
 
-doc/rust.pdf: doc/rust.tex
-	@$(call E, pdflatex: $@)
-	$(Q)$(CFG_PDFLATEX) \
-        -interaction=batchmode \
-        -output-directory=doc \
-        $<
-
-      endif
-    endif
-  endif
-
 DOCS += doc/rustpkg.html
 doc/rustpkg.html: rustpkg.md doc/version_info.html doc/rust.css doc/manual.css
 	@$(call E, pandoc: $@)
@@ -95,13 +78,6 @@ doc/rustpkg.html: rustpkg.md doc/version_info.html doc/rust.css doc/manual.css
 	     --include-before-body=doc/version_info.html \
          --output=$@
 
-######################################################################
-# Node (tutorial related)
-######################################################################
-  ifeq ($(CFG_NODE),)
-    $(info cfg: no node found, omitting doc/tutorial.html)
-  else
-
 DOCS += doc/tutorial.html
 doc/tutorial.html: tutorial.md doc/version_info.html doc/rust.css
 	@$(call E, pandoc: $@)
@@ -153,9 +129,29 @@ doc/tutorial-tasks.html: tutorial-tasks.md doc/version_info.html doc/rust.css
 	   --include-before-body=doc/version_info.html \
            --output=$@
 
+  ifeq ($(CFG_PDFLATEX),)
+    $(info cfg: no pdflatex found, omitting doc/rust.pdf)
+  else
+    ifeq ($(CFG_XETEX),)
+      $(info cfg: no xetex found, disabling doc/rust.pdf)
+    else
+      ifeq ($(CFG_LUATEX),)
+        $(info cfg: lacking luatex, disabling pdflatex)
+      else
+
+DOCS += doc/rust.pdf
+doc/rust.pdf: doc/rust.tex
+	@$(call E, pdflatex: $@)
+	$(Q)$(CFG_PDFLATEX) \
+        -interaction=batchmode \
+        -output-directory=doc \
+        $<
+
+      endif
+    endif
   endif
-endif
 
+endif # No pandoc / node
 
 ######################################################################
 # LLnextgen (grammar analysis from refman)
diff --git a/mk/host.mk b/mk/host.mk
index 13a8a540117..0c00a7e1d64 100644
--- a/mk/host.mk
+++ b/mk/host.mk
@@ -29,7 +29,9 @@ $$(HBIN$(2)_H_$(4))/rustc$$(X_$(4)): \
 	$$(HLIB$(2)_H_$(4))/$(CFG_RUSTLLVM_$(4)) \
 	$$(HLIB$(2)_H_$(4))/$(CFG_LIBRUSTC_$(4)) \
 	$$(HCORELIB_DEFAULT$(2)_H_$(4)) \
-	$$(HSTDLIB_DEFAULT$(2)_H_$(4))
+	$$(HSTDLIB_DEFAULT$(2)_H_$(4)) \
+	| $$(HBIN$(2)_H_$(4))/
+
 	@$$(call E, cp: $$@)
 	$$(Q)cp $$< $$@
 
@@ -39,7 +41,9 @@ $$(HLIB$(2)_H_$(4))/$(CFG_LIBRUSTC_$(4)): \
 	$$(HLIB$(2)_H_$(4))/$(CFG_RUNTIME_$(4)) \
 	$$(HLIB$(2)_H_$(4))/$(CFG_RUSTLLVM_$(4)) \
 	$$(HCORELIB_DEFAULT$(2)_H_$(4)) \
-	$$(HSTDLIB_DEFAULT$(2)_H_$(4))
+	$$(HSTDLIB_DEFAULT$(2)_H_$(4)) \
+	| $$(HLIB$(2)_H_$(4))/
+
 	@$$(call E, cp: $$@)
 	$$(Q)cp $$< $$@
 	$$(Q)cp -R $$(TLIB$(1)_T_$(4)_H_$(3))/$(LIBRUSTC_GLOB_$(4)) \
@@ -51,7 +55,8 @@ $$(HLIB$(2)_H_$(4))/$(CFG_LIBSYNTAX_$(4)): \
 	$$(HLIB$(2)_H_$(4))/$(CFG_RUNTIME_$(4)) \
 	$$(HLIB$(2)_H_$(4))/$(CFG_RUSTLLVM_$(4)) \
 	$$(HCORELIB_DEFAULT$(2)_H_$(4)) \
-	$$(HSTDLIB_DEFAULT$(2)_H_$(4))
+	$$(HSTDLIB_DEFAULT$(2)_H_$(4)) \
+	| $$(HLIB$(2)_H_$(4))/
 	@$$(call E, cp: $$@)
 	$$(Q)cp $$< $$@
 	$$(Q)cp -R $$(TLIB$(1)_T_$(4)_H_$(3))/$(LIBSYNTAX_GLOB_$(4)) \
@@ -59,13 +64,15 @@ $$(HLIB$(2)_H_$(4))/$(CFG_LIBSYNTAX_$(4)): \
 	        $$(HLIB$(2)_H_$(4))
 
 $$(HLIB$(2)_H_$(4))/$(CFG_RUNTIME_$(4)): \
-	$$(TLIB$(1)_T_$(4)_H_$(3))/$(CFG_RUNTIME_$(4))
+	$$(TLIB$(1)_T_$(4)_H_$(3))/$(CFG_RUNTIME_$(4)) \
+	| $$(HLIB$(2)_H_$(4))/
 	@$$(call E, cp: $$@)
 	$$(Q)cp $$< $$@
 
 $$(HLIB$(2)_H_$(4))/$(CFG_CORELIB_$(4)): \
 	$$(TLIB$(1)_T_$(4)_H_$(3))/$(CFG_CORELIB_$(4)) \
-	$$(HLIB$(2)_H_$(4))/$(CFG_RUNTIME_$(4))
+	$$(HLIB$(2)_H_$(4))/$(CFG_RUNTIME_$(4)) \
+	| $$(HLIB$(2)_H_$(4))/
 	@$$(call E, cp: $$@)
 	$$(Q)cp $$< $$@
 # Subtle: We do not let the shell expand $(CORELIB_DSYM_GLOB) directly rather
@@ -82,7 +89,8 @@ $$(HLIB$(2)_H_$(4))/$(CFG_CORELIB_$(4)): \
 $$(HLIB$(2)_H_$(4))/$(CFG_STDLIB_$(4)): \
 	$$(TLIB$(1)_T_$(4)_H_$(3))/$(CFG_STDLIB_$(4)) \
 	$$(HLIB$(2)_H_$(4))/$(CFG_CORELIB_$(4)) \
-	$$(HLIB$(2)_H_$(4))/$(CFG_RUNTIME_$(4))
+	$$(HLIB$(2)_H_$(4))/$(CFG_RUNTIME_$(4)) \
+	| $$(HLIB$(2)_H_$(4))/
 	@$$(call E, cp: $$@)
 	$$(Q)cp $$< $$@
 	$$(Q)cp -R $$(TLIB$(1)_T_$(4)_H_$(3))/$(STDLIB_GLOB_$(4)) \
@@ -91,14 +99,16 @@ $$(HLIB$(2)_H_$(4))/$(CFG_STDLIB_$(4)): \
 
 $$(HLIB$(2)_H_$(4))/libcore.rlib: \
 	$$(TLIB$(1)_T_$(4)_H_$(3))/libcore.rlib \
-	$$(HLIB$(2)_H_$(4))/$$(CFG_RUNTIME_$(4))
+	$$(HLIB$(2)_H_$(4))/$$(CFG_RUNTIME_$(4)) \
+	| $$(HLIB$(2)_H_$(4))/
 	@$$(call E, cp: $$@)
 	$$(Q)cp $$< $$@
 
 $$(HLIB$(2)_H_$(4))/libstd.rlib: \
 	$$(TLIB$(1)_T_$(4)_H_$(3))/libstd.rlib \
 	$$(HLIB$(2)_H_$(4))/libcore.rlib \
-	$$(HLIB$(2)_H_$(4))/$$(CFG_RUNTIME_$(4))
+	$$(HLIB$(2)_H_$(4))/$$(CFG_RUNTIME_$(4)) \
+	| $$(HLIB$(2)_H_$(4))/
 	@$$(call E, cp: $$@)
 	$$(Q)cp $$< $$@
 
@@ -106,15 +116,23 @@ $$(HLIB$(2)_H_$(4))/librustc.rlib: \
 	$$(TLIB$(1)_T_$(4)_H_$(3))/librustc.rlib \
 	$$(HLIB$(2)_H_$(4))/libcore.rlib \
 	$$(HLIB$(2)_H_$(4))/libstd.rlib \
-	$$(HLIB$(2)_H_$(4))/$$(CFG_RUNTIME_$(4))
+	$$(HLIB$(2)_H_$(4))/$$(CFG_RUNTIME_$(4)) \
+	| $$(HLIB$(2)_H_$(4))/
 	@$$(call E, cp: $$@)
 	$$(Q)cp $$< $$@
 
 $$(HLIB$(2)_H_$(4))/$(CFG_RUSTLLVM_$(4)): \
-	$$(TLIB$(1)_T_$(4)_H_$(3))/$(CFG_RUSTLLVM_$(4))
+	$$(TLIB$(1)_T_$(4)_H_$(3))/$(CFG_RUSTLLVM_$(4)) \
+	| $$(HLIB$(2)_H_$(4))/
 	@$$(call E, cp: $$@)
 	$$(Q)cp $$< $$@
 
+$$(HBIN$(2)_H_$(4))/:
+	mkdir -p $$@
+
+$$(HLIB$(2)_H_$(4))/:
+	mkdir -p $$@
+
 endef
 
 $(foreach t,$(CFG_HOST_TRIPLES),					\
diff --git a/mk/platform.mk b/mk/platform.mk
index 1e102587bf4..e03b7c15247 100644
--- a/mk/platform.mk
+++ b/mk/platform.mk
@@ -11,7 +11,7 @@
 
 # Create variables HOST_<triple> containing the host part
 # of each target triple.  For example, the triple i686-darwin-macos
-# would create a variable HOST_i686-darwin-macos with the value 
+# would create a variable HOST_i686-darwin-macos with the value
 # i386.
 define DEF_HOST_VAR
   HOST_$(1) = $(subst i686,i386,$(word 1,$(subst -, ,$(1))))
@@ -276,8 +276,8 @@ CFG_GCCISH_CFLAGS_i686-pc-mingw32 := -Wall -Werror -g -march=i686
 CFG_GCCISH_CXXFLAGS_i686-pc-mingw32 := -fno-rtti
 CFG_GCCISH_LINK_FLAGS_i686-pc-mingw32 := -shared -fPIC -g
 CFG_GCCISH_DEF_FLAG_i686-pc-mingw32 :=
-CFG_GCCISH_PRE_LIB_FLAGS_i686-pc-mingw32 := 
-CFG_GCCISH_POST_LIB_FLAGS_i686-pc-mingw32 := 
+CFG_GCCISH_PRE_LIB_FLAGS_i686-pc-mingw32 :=
+CFG_GCCISH_POST_LIB_FLAGS_i686-pc-mingw32 :=
 CFG_DEF_SUFFIX_i686-pc-mingw32 := .mingw32.def
 CFG_INSTALL_NAME_i686-pc-mingw32 =
 CFG_LIBUV_LINK_FLAGS_i686-pc-mingw32 := -lWs2_32 -lpsapi -liphlpapi
diff --git a/mk/rt.mk b/mk/rt.mk
index 015992abf78..30dda2fb276 100644
--- a/mk/rt.mk
+++ b/mk/rt.mk
@@ -1,27 +1,27 @@
 # This is a procedure to define the targets for building
-# the runtime.  
+# the runtime.
 #
 # Argument 1 is the target triple.
 #
 # This is not really the right place to explain this, but
 # for those of you who are not Makefile gurus, let me briefly
-# cover the $ expansion system in use here, because it 
+# cover the $ expansion system in use here, because it
 # confused me for a while!  The variable DEF_RUNTIME_TARGETS
 # will be defined once and then expanded with different
 # values substituted for $(1) each time it is called.
-# That resulting text is then eval'd. 
+# That resulting text is then eval'd.
 #
 # For most variables, you could use a single $ sign.  The result
 # is that the substitution would occur when the CALL occurs,
 # I believe.  The problem is that the automatic variables $< and $@
 # need to be expanded-per-rule.  Therefore, for those variables at
-# least, you need $$< and $$@ in the variable text.  This way, after 
+# least, you need $$< and $$@ in the variable text.  This way, after
 # the CALL substitution occurs, you will have $< and $@.  This text
 # will then be evaluated, and all will work as you like.
 #
 # Reader beware, this explanantion could be wrong, but it seems to
-# fit the experimental data (i.e., I was able to get the system 
-# working under these assumptions). 
+# fit the experimental data (i.e., I was able to get the system
+# working under these assumptions).
 
 # Hack for passing flags into LIBUV, see below.
 LIBUV_FLAGS_i386 = -m32 -fPIC
@@ -163,14 +163,16 @@ endif
 ifdef CFG_WINDOWSY_$(1)
 $$(LIBUV_LIB_$(1)): $$(LIBUV_DEPS)
 	$$(Q)$$(MAKE) -C $$(S)src/libuv/ \
+		CFLAGS="$$(CFG_GCCISH_CFLAGS)" \
+		LDFLAGS="$$(CFG_GCCISH_LINK_FLAGS)" \
 		builddir_name="$$(CFG_BUILD_DIR)/rt/$(1)/libuv" \
 		OS=mingw \
 		V=$$(VERBOSE)
 else ifeq ($(OSTYPE_$(1)), linux-androideabi)
 $$(LIBUV_LIB_$(1)): $$(LIBUV_DEPS)
 	$$(Q)$$(MAKE) -C $$(S)src/libuv/ \
-		CFLAGS="$$(LIBUV_FLAGS_$$(HOST_$(1))) $$(SNAP_DEFINES)" \
-		LDFLAGS="$$(LIBUV_FLAGS_$$(HOST_$(1)))" \
+		CFLAGS="$$(CFG_GCCISH_CFLAGS) $$(LIBUV_FLAGS_$$(HOST_$(1))) $$(SNAP_DEFINES)" \
+		LDFLAGS="$$(CFG_GCCISH_LINK_FLAGS) $$(LIBUV_FLAGS_$$(HOST_$(1)))" \
 		CC="$$(CC_$(1))" \
 		CXX="$$(CXX_$(1))" \
 		AR="$$(AR_$(1))" \
@@ -181,8 +183,8 @@ $$(LIBUV_LIB_$(1)): $$(LIBUV_DEPS)
 else
 $$(LIBUV_LIB_$(1)): $$(LIBUV_DEPS)
 	$$(Q)$$(MAKE) -C $$(S)src/libuv/ \
-		CFLAGS="$$(LIBUV_FLAGS_$$(HOST_$(1))) $$(SNAP_DEFINES)" \
-		LDFLAGS="$$(LIBUV_FLAGS_$$(HOST_$(1)))" \
+		CFLAGS="$$(CFG_GCCISH_CFLAGS) $$(LIBUV_FLAGS_$$(HOST_$(1))) $$(SNAP_DEFINES)" \
+		LDFLAGS="$$(CFG_GCCISH_LINK_FLAGS) $$(LIBUV_FLAGS_$$(HOST_$(1)))" \
 		CC="$$(CC_$(1))" \
 		CXX="$$(CXX_$(1))" \
 		AR="$$(AR_$(1))" \
diff --git a/mk/stage0.mk b/mk/stage0.mk
index 7b5cbef1d72..ac1b3e86ac9 100644
--- a/mk/stage0.mk
+++ b/mk/stage0.mk
@@ -7,16 +7,16 @@ $(HBIN0_H_$(CFG_BUILD_TRIPLE))/rustc$(X_$(CFG_BUILD_TRIPLE)):		\
 		$(S)src/etc/get-snapshot.py $(MKFILE_DEPS)
 	@$(call E, fetch: $@)
 #   Note: the variable "SNAPSHOT_FILE" is generally not set, and so
-#   we generally only pass one argument to this script.  
+#   we generally only pass one argument to this script.
 ifdef CFG_ENABLE_LOCAL_RUST
 	$(Q)$(S)src/etc/local_stage0.sh $(CFG_BUILD_TRIPLE) $(CFG_LOCAL_RUST_ROOT)
-else 
+else
 	$(Q)$(CFG_PYTHON) $(S)src/etc/get-snapshot.py $(CFG_BUILD_TRIPLE) $(SNAPSHOT_FILE)
 ifdef CFG_ENABLE_PAX_FLAGS
 	@$(call E, apply PaX flags: $@)
 	@"$(CFG_PAXCTL)" -cm "$@"
 endif
-endif 
+endif
 	$(Q)touch $@
 
 # Host libs will be extracted by the above rule
diff --git a/mk/target.mk b/mk/target.mk
index fba1a6e0ee5..2223531c3ec 100644
--- a/mk/target.mk
+++ b/mk/target.mk
@@ -18,25 +18,29 @@
 define TARGET_STAGE_N
 
 $$(TLIB$(1)_T_$(2)_H_$(3))/libmorestack.a: \
-		rt/$(2)/arch/$$(HOST_$(2))/libmorestack.a
+		rt/$(2)/arch/$$(HOST_$(2))/libmorestack.a \
+		| $$(TLIB$(1)_T_$(2)_H_$(3))/
 	@$$(call E, cp: $$@)
 	$$(Q)cp $$< $$@
 
 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_RUNTIME_$(2)): \
-		rt/$(2)/$(CFG_RUNTIME_$(2))
+		rt/$(2)/$(CFG_RUNTIME_$(2)) \
+		| $$(TLIB$(1)_T_$(2)_H_$(3))/
 	@$$(call E, cp: $$@)
 	$$(Q)cp $$< $$@
 
 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_CORELIB_$(2)): \
 		$$(CORELIB_CRATE) $$(CORELIB_INPUTS) \
-		$$(TSREQ$(1)_T_$(2)_H_$(3))
+		$$(TSREQ$(1)_T_$(2)_H_$(3)) \
+		| $$(TLIB$(1)_T_$(2)_H_$(3))/
 	@$$(call E, compile_and_link: $$@)
 	$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< && touch $$@
 
 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_STDLIB_$(2)): \
 		$$(STDLIB_CRATE) $$(STDLIB_INPUTS) \
 	        $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_CORELIB_$(2)) \
-		$$(TSREQ$(1)_T_$(2)_H_$(3))
+		$$(TSREQ$(1)_T_$(2)_H_$(3)) \
+		| $$(TLIB$(1)_T_$(2)_H_$(3))/
 	@$$(call E, compile_and_link: $$@)
 	$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< && touch $$@
 
@@ -44,7 +48,8 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBSYNTAX_$(3)): \
                 $$(LIBSYNTAX_CRATE) $$(LIBSYNTAX_INPUTS) \
 		$$(TSREQ$(1)_T_$(2)_H_$(3))			\
 		$$(TCORELIB_DEFAULT$(1)_T_$(2)_H_$(3))      \
-		$$(TSTDLIB_DEFAULT$(1)_T_$(2)_H_$(3))
+		$$(TSTDLIB_DEFAULT$(1)_T_$(2)_H_$(3)) \
+		| $$(TLIB$(1)_T_$(2)_H_$(3))/
 	@$$(call E, compile_and_link: $$@)
 	$$(STAGE$(1)_T_$(2)_H_$(3)) $(BORROWCK) -o $$@ $$< && touch $$@
 
@@ -52,20 +57,23 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBSYNTAX_$(3)): \
 ifneq ($$(findstring $(2),$$(CFG_HOST_TRIPLES)),)
 
 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_RUSTLLVM_$(3)): \
-		rustllvm/$(2)/$(CFG_RUSTLLVM_$(3))
+		rustllvm/$(2)/$(CFG_RUSTLLVM_$(3)) \
+		| $$(TLIB$(1)_T_$(2)_H_$(3))/
 	@$$(call E, cp: $$@)
 	$$(Q)cp $$< $$@
 
 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTC_$(3)):		\
 		$$(COMPILER_CRATE) $$(COMPILER_INPUTS)		\
                 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBSYNTAX_$(3)) \
-                $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_RUSTLLVM_$(3))
+                $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_RUSTLLVM_$(3)) \
+		| $$(TLIB$(1)_T_$(2)_H_$(3))/
 	@$$(call E, compile_and_link: $$@)
 	$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< && touch $$@
 
 $$(TBIN$(1)_T_$(2)_H_$(3))/rustc$$(X_$(3)):			\
-		$$(DRIVER_CRATE) 							\
-		$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTC_$(3))
+		$$(DRIVER_CRATE)				\
+		$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTC_$(3)) \
+		| $$(TBIN$(1)_T_$(2)_H_$(3))/
 	@$$(call E, compile_and_link: $$@)
 	$$(STAGE$(1)_T_$(2)_H_$(3)) --cfg rustc -o $$@ $$<
 ifdef CFG_ENABLE_PAX_FLAGS
@@ -75,6 +83,12 @@ endif
 
 endif
 
+$$(TBIN$(1)_T_$(2)_H_$(3))/:
+	mkdir -p $$@
+
+$$(TLIB$(1)_T_$(2)_H_$(3))/:
+	mkdir -p $$@
+
 endef
 
 # In principle, each host can build each target:
diff --git a/mk/tests.mk b/mk/tests.mk
index f96b7325f60..175e33c6654 100644
--- a/mk/tests.mk
+++ b/mk/tests.mk
@@ -179,9 +179,9 @@ tidy:
 		$(Q)find $(S)src/etc -name '*.py' \
 		| xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
 		$(Q)echo $(ALL_CS) \
-	  	| xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
+		| xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
 		$(Q)echo $(ALL_HS) \
-	  	| xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
+		| xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
 
 endif
 
@@ -709,4 +709,3 @@ endef
 
 $(foreach host,$(CFG_HOST_TRIPLES),			\
  $(eval $(call DEF_CHECK_FAST_FOR_H,$(host))))
-
diff --git a/src/compiletest/compiletest.rc b/src/compiletest/compiletest.rc
index 4392ce7ba28..b6d690f8307 100644
--- a/src/compiletest/compiletest.rc
+++ b/src/compiletest/compiletest.rc
@@ -223,10 +223,3 @@ pub fn make_test_closure(config: config, testfile: &Path) -> test::TestFn {
     let testfile = testfile.to_str();
     test::DynTestFn(|| runtest::run(config, testfile))
 }
-
-// Local Variables:
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
diff --git a/src/etc/check-links.pl b/src/etc/check-links.pl
index a280ed55ba9..6492be53d34 100755
--- a/src/etc/check-links.pl
+++ b/src/etc/check-links.pl
@@ -9,7 +9,7 @@ my $anchors = {};
 my $i = 0;
 foreach $line (@lines) {
     $i++;
-    if ($line =~ m/id="([^"]+)"/) { 
+    if ($line =~ m/id="([^"]+)"/) {
         $anchors->{$1} = $i;
     }
 }
@@ -17,10 +17,9 @@ foreach $line (@lines) {
 $i = 0;
 foreach $line (@lines) {
     $i++;
-    while ($line =~ m/href="#([^"]+)"/g) { 
+    while ($line =~ m/href="#([^"]+)"/g) {
         if (! exists($anchors->{$1})) {
             print "$file:$i: $1 referenced\n";
         }
     }
 }
-
diff --git a/src/etc/gedit/readme.txt b/src/etc/gedit/readme.txt
index 735b0236276..e394f191608 100644
--- a/src/etc/gedit/readme.txt
+++ b/src/etc/gedit/readme.txt
@@ -8,4 +8,3 @@ Instructions for Ubuntu Linux 12.04+
 2) Copy the included "share" folder into "~/.local/"
 
 3) Open a shell in "~/.local/share/" and run "update-mime-database mime"
-
diff --git a/src/etc/gedit/share/gtksourceview-3.0/language-specs/rust.lang b/src/etc/gedit/share/gtksourceview-3.0/language-specs/rust.lang
index 0b23808b765..a413d0a9062 100644
--- a/src/etc/gedit/share/gtksourceview-3.0/language-specs/rust.lang
+++ b/src/etc/gedit/share/gtksourceview-3.0/language-specs/rust.lang
@@ -123,11 +123,11 @@
 		<keyword>mode_t</keyword>
 		<keyword>ssize_t</keyword>
     </context>
-    
+
     <context id="self" style-ref="identifier">
 		<keyword>self</keyword>
     </context>
-    
+
     <context id="constants" style-ref="constant">
 		<keyword>true</keyword>
 		<keyword>false</keyword>
@@ -261,4 +261,3 @@
   </definitions>
 
 </language>
-
diff --git a/src/etc/gedit/share/mime/packages/rust.xml b/src/etc/gedit/share/mime/packages/rust.xml
index 65168aae1d9..d75cffe9600 100644
--- a/src/etc/gedit/share/mime/packages/rust.xml
+++ b/src/etc/gedit/share/mime/packages/rust.xml
@@ -2,6 +2,6 @@
   <mime-type type="text/x-rust">
     <comment>Rust Source</comment>
     <glob pattern="*.rs"/>
-    <glob pattern="*.rc"/>    
+    <glob pattern="*.rc"/>
   </mime-type>
 </mime-info>
diff --git a/src/etc/indenter b/src/etc/indenter
index 017cb926981..1a3a4465335 100755
--- a/src/etc/indenter
+++ b/src/etc/indenter
@@ -14,4 +14,3 @@ while (<>) {
         $indent -= 1;
     }
 }
-
diff --git a/src/etc/latest-unix-snaps.py b/src/etc/latest-unix-snaps.py
index 7a2ddba3a16..7cecf837161 100755
--- a/src/etc/latest-unix-snaps.py
+++ b/src/etc/latest-unix-snaps.py
@@ -52,5 +52,3 @@ def download_new_file (date, rev, platform, hsh):
 for ff in newestSet["files"]:
    download_new_file (newestSet["date"], newestSet["rev"],
                       ff["platform"], ff["hash"])
-
-
diff --git a/src/etc/libc.c b/src/etc/libc.c
index 9acc122f32b..e341f495eeb 100644
--- a/src/etc/libc.c
+++ b/src/etc/libc.c
@@ -243,4 +243,3 @@ int main() {
   extra_consts();
   printf("}\n");
 }
-
diff --git a/src/etc/licenseck.py b/src/etc/licenseck.py
index 973b7deb960..1e0c541cd89 100644
--- a/src/etc/licenseck.py
+++ b/src/etc/licenseck.py
@@ -96,4 +96,3 @@ def check_license(name, contents):
         return True
 
     return False
-
diff --git a/src/etc/local_stage0.sh b/src/etc/local_stage0.sh
index 5898bc561aa..8d2fd887e3f 100755
--- a/src/etc/local_stage0.sh
+++ b/src/etc/local_stage0.sh
@@ -1,13 +1,13 @@
 #!/bin/sh
 
-TARG_DIR=$1 
+TARG_DIR=$1
 PREFIX=$2
 
 BINDIR=bin
 LIBDIR=lib
 
 OS=`uname -s`
-case $OS in 
+case $OS in
     ("Linux"|"FreeBSD")
 	BIN_SUF=
 	LIB_SUF=.so
diff --git a/src/etc/mirror-all-snapshots.py b/src/etc/mirror-all-snapshots.py
index f1fce7a94b5..3b5f66c4117 100644
--- a/src/etc/mirror-all-snapshots.py
+++ b/src/etc/mirror-all-snapshots.py
@@ -33,6 +33,3 @@ for line in f.readlines():
             print("got download with ok hash")
         else:
             raise Exception("bad hash on download")
-
-
-
diff --git a/src/etc/monodebug.pl b/src/etc/monodebug.pl
index 324c576a4bd..a2d27591cad 100755
--- a/src/etc/monodebug.pl
+++ b/src/etc/monodebug.pl
@@ -77,4 +77,3 @@ while (my ($key, $substs) = each %funcs) {
     }
     print "\n";
 }
-
diff --git a/src/etc/sugarise-doc-comments.py b/src/etc/sugarise-doc-comments.py
index 6399cff6b88..7bd4175fbf0 100755
--- a/src/etc/sugarise-doc-comments.py
+++ b/src/etc/sugarise-doc-comments.py
@@ -80,4 +80,3 @@ def sugarise_file(path):
 for (dirpath, dirnames, filenames) in os.walk('.'):
     for name in fnmatch.filter(filenames, '*.r[sc]'):
         sugarise_file(os.path.join(dirpath, name))
-
diff --git a/src/etc/tidy.py b/src/etc/tidy.py
index a5cf6141567..06fcb5cb945 100644
--- a/src/etc/tidy.py
+++ b/src/etc/tidy.py
@@ -81,4 +81,3 @@ except UnicodeDecodeError, e:
 
 
 sys.exit(err)
-
diff --git a/src/etc/unicode.py b/src/etc/unicode.py
index 864cf3daee0..afb3d168480 100755
--- a/src/etc/unicode.py
+++ b/src/etc/unicode.py
@@ -235,6 +235,10 @@ for i in [r]:
 rf = open(r, "w")
 
 (canon_decomp, compat_decomp, gencats) = load_unicode_data("UnicodeData.txt")
+
+# Explain that the source code was generated by this script.
+rf.write('// The following code was generated by "src/etc/unicode.py"\n\n')
+
 emit_property_module(rf, "general_category", gencats)
 
 #emit_decomp_module(rf, canon_decomp, compat_decomp)
diff --git a/src/etc/x86.supp b/src/etc/x86.supp
index 417f4c9d2c1..def1c5a53c1 100644
--- a/src/etc/x86.supp
+++ b/src/etc/x86.supp
@@ -366,7 +366,7 @@
    ...
 }
 
-{  
+{
    llvm-user-new-leak
    Memcheck:Leak
    fun:_Znwj
@@ -401,7 +401,7 @@
    Helgrind:Race
    fun:_ZN15lock_and_signal27lock_held_by_current_threadEv
    ...
-}  
+}
 
 {
    lock_and_signal-probably-threadsafe-access-outside-of-lock2
diff --git a/src/etc/ziggurat_tables.py b/src/etc/ziggurat_tables.py
new file mode 100755
index 00000000000..c8f873037d8
--- /dev/null
+++ b/src/etc/ziggurat_tables.py
@@ -0,0 +1,121 @@
+#!/usr/bin/env python
+# xfail-license
+
+# This creates the tables used for distributions implemented using the
+# ziggurat algorithm in `core::rand::distributions;`. They are
+# (basically) the tables as used in the ZIGNOR variant (Doornik 2005).
+# They are changed rarely, so the generated file should be checked in
+# to git.
+#
+# It creates 3 tables: X as in the paper, F which is f(x_i), and
+# F_DIFF which is f(x_i) - f(x_{i-1}). The latter two are just cached
+# values which is not done in that paper (but is done in other
+# variants). Note that the adZigR table is unnecessary because of
+# algebra.
+#
+# It is designed to be compatible with Python 2 and 3.
+
+from math import exp, sqrt, log, floor
+import random
+
+# The order should match the return value of `tables`
+TABLE_NAMES = ['X', 'F', 'F_DIFF']
+
+# The actual length of the table is 1 more, to stop
+# index-out-of-bounds errors. This should match the bitwise operation
+# to find `i` in `zigurrat` in `libstd/rand/mod.rs`. Also the *_R and
+# *_V constants below depend on this value.
+TABLE_LEN = 256
+
+# equivalent to `zigNorInit` in Doornik2005, but generalised to any
+# distribution. r = dR, v = dV, f = probability density function,
+# f_inv = inverse of f
+def tables(r, v, f, f_inv):
+    # compute the x_i
+    xvec = [0]*(TABLE_LEN+1)
+
+    xvec[0] = v / f(r)
+    xvec[1] = r
+
+    for i in range(2, TABLE_LEN):
+        last = xvec[i-1]
+        xvec[i] = f_inv(v / last + f(last))
+
+    # cache the f's
+    fvec = [0]*(TABLE_LEN+1)
+    fdiff = [0]*(TABLE_LEN+1)
+    for i in range(TABLE_LEN+1):
+        fvec[i] = f(xvec[i])
+        if i > 0:
+            fdiff[i] = fvec[i] - fvec[i-1]
+
+    return xvec, fvec, fdiff
+
+# Distributions
+# N(0, 1)
+def norm_f(x):
+    return exp(-x*x/2.0)
+def norm_f_inv(y):
+    return sqrt(-2.0*log(y))
+
+NORM_R = 3.6541528853610088
+NORM_V = 0.00492867323399
+
+NORM = tables(NORM_R, NORM_V,
+              norm_f, norm_f_inv)
+
+# Exp(1)
+def exp_f(x):
+    return exp(-x)
+def exp_f_inv(y):
+    return -log(y)
+
+EXP_R = 7.69711747013104972
+EXP_V = 0.0039496598225815571993
+
+EXP = tables(EXP_R, EXP_V,
+             exp_f, exp_f_inv)
+
+
+# Output the tables/constants/types
+
+def render_static(name, type, value):
+    # no space or
+    return 'pub static %s: %s =%s;\n' % (name, type, value)
+
+# static `name`: [`type`, .. `len(values)`] =
+#     [values[0], ..., values[3],
+#      values[4], ..., values[7],
+#      ... ];
+def render_table(name, values):
+    rows = []
+    # 4 values on each row
+    for i in range(0, len(values), 4):
+        row = values[i:i+4]
+        rows.append(', '.join('%.18f' % f for f in row))
+
+    rendered = '\n    [%s]' % ',\n     '.join(rows)
+    return render_static(name, '[f64, .. %d]' % len(values), rendered)
+
+
+with open('ziggurat_tables.rs', 'w') as f:
+    f.write('''// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Tables for distributions which are sampled using the ziggurat
+// algorithm. Autogenerated by `ziggurat_tables.py`.
+
+pub type ZigTable = &\'static [f64, .. %d];
+'''  % (TABLE_LEN + 1))
+    for name, tables, r in [('NORM', NORM, NORM_R),
+                            ('EXP', EXP, EXP_R)]:
+        f.write(render_static('ZIG_%s_R' % name, 'f64', ' %.18f' % r))
+        for (tabname, table) in zip(TABLE_NAMES, tables):
+            f.write(render_table('ZIG_%s_%s' % (name, tabname), table))
diff --git a/src/libcore/bool.rs b/src/libcore/bool.rs
index 6c60cec2595..1b4b81dca26 100644
--- a/src/libcore/bool.rs
+++ b/src/libcore/bool.rs
@@ -108,8 +108,6 @@ mod tests {
 
     #[test]
     fn test_bool_from_str() {
-        use from_str::FromStr;
-
         do all_values |v| {
             assert!(Some(v) == FromStr::from_str(to_str(v)))
         }
diff --git a/src/libcore/cast.rs b/src/libcore/cast.rs
index 6fb737d3770..96e1c3bd124 100644
--- a/src/libcore/cast.rs
+++ b/src/libcore/cast.rs
@@ -19,35 +19,11 @@ pub mod rusti {
     pub extern "rust-intrinsic" {
         fn forget<T>(+x: T);
 
-        #[cfg(stage0)]
-        fn reinterpret_cast<T, U>(&&e: T) -> U;
-
-        #[cfg(stage1)]
-        #[cfg(stage2)]
-        #[cfg(stage3)]
         fn transmute<T,U>(e: T) -> U;
     }
 }
 
 /// Casts the value at `src` to U. The two types must have the same length.
-#[inline(always)]
-#[cfg(stage0)]
-pub unsafe fn reinterpret_cast<T, U>(src: &T) -> U {
-    rusti::reinterpret_cast(*src)
-}
-
-/// Unsafely copies and casts the value at `src` to U, even if the value is
-/// noncopyable. The two types must have the same length.
-#[inline(always)]
-#[cfg(stage0)]
-pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
-    rusti::reinterpret_cast(*src)
-}
-
-#[inline(always)]
-#[cfg(stage1)]
-#[cfg(stage2)]
-#[cfg(stage3)]
 pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
     let mut dest: U = unstable::intrinsics::init();
     {
@@ -88,17 +64,6 @@ pub unsafe fn bump_box_refcount<T>(t: @T) { forget(t); }
  *     assert!(transmute("L") == ~[76u8, 0u8]);
  */
 #[inline(always)]
-#[cfg(stage0)]
-pub unsafe fn transmute<L, G>(thing: L) -> G {
-    let newthing: G = reinterpret_cast(&thing);
-    forget(thing);
-    newthing
-}
-
-#[inline(always)]
-#[cfg(stage1)]
-#[cfg(stage2)]
-#[cfg(stage3)]
 pub unsafe fn transmute<L, G>(thing: L) -> G {
     rusti::transmute(thing)
 }
@@ -159,15 +124,6 @@ mod tests {
     use cast::{bump_box_refcount, transmute};
 
     #[test]
-    #[cfg(stage0)]
-    fn test_reinterpret_cast() {
-        assert!(1u == unsafe { ::cast::reinterpret_cast(&1) });
-    }
-
-    #[test]
-    #[cfg(stage1)]
-    #[cfg(stage2)]
-    #[cfg(stage3)]
     fn test_transmute_copy() {
         assert!(1u == unsafe { ::cast::transmute_copy(&1) });
     }
diff --git a/src/libcore/char.rs b/src/libcore/char.rs
index ef2bd91e973..7868b463807 100644
--- a/src/libcore/char.rs
+++ b/src/libcore/char.rs
@@ -10,6 +10,7 @@
 
 //! Utilities for manipulating the char type
 
+#[cfg(notest)]
 use cmp::Ord;
 use option::{None, Option, Some};
 use str;
diff --git a/src/libcore/cleanup.rs b/src/libcore/cleanup.rs
index 3f7366c6c45..435b1cb7f34 100644
--- a/src/libcore/cleanup.rs
+++ b/src/libcore/cleanup.rs
@@ -258,4 +258,3 @@ pub mod rustrt {
         pub unsafe fn rust_get_task() -> *c_void;
     }
 }
-
diff --git a/src/libcore/condition.rs b/src/libcore/condition.rs
index dc6c80228dd..1240fe03dd5 100644
--- a/src/libcore/condition.rs
+++ b/src/libcore/condition.rs
@@ -192,4 +192,27 @@ mod test {
 
         assert!(trapped);
     }
+
+    // Issue #6009
+    mod m {
+        condition! {
+            sadness: int -> int;
+        }
+
+        mod n {
+            use super::sadness;
+
+            #[test]
+            fn test_conditions_are_public() {
+                let mut trapped = false;
+                do sadness::cond.trap(|_| {
+                    trapped = true;
+                    0
+                }).in {
+                    sadness::cond.raise(0);
+                }
+                assert!(trapped);
+            }
+        }
+    }
 }
diff --git a/src/libcore/core.rc b/src/libcore/core.rc
index f6e4056f3d0..9672bf887ca 100644
--- a/src/libcore/core.rc
+++ b/src/libcore/core.rc
@@ -63,7 +63,6 @@ they contained the following prologue:
 #[warn(vecs_implicitly_copyable)];
 #[deny(non_camel_case_types)];
 #[allow(deprecated_mutable_fields)];
-#[allow(deprecated_drop)];
 
 // Make core testable by not duplicating lang items. See #2912
 #[cfg(test)] extern mod realcore(name = "core", vers = "0.7-pre");
@@ -75,7 +74,7 @@ they contained the following prologue:
 
 pub use kinds::{Const, Copy, Owned, Durable};
 pub use ops::{Drop};
-pub use ops::{Add, Sub, Mul, Quot, Rem, Neg, Not};
+pub use ops::{Add, Sub, Mul, Div, Rem, Neg, Not};
 pub use ops::{BitAnd, BitOr, BitXor};
 pub use ops::{Shl, Shr, Index};
 
@@ -109,6 +108,7 @@ pub use num::{Bitwise, BitCount, Bounded};
 pub use num::{Primitive, Int, Float};
 
 pub use ptr::Ptr;
+pub use from_str::FromStr;
 pub use to_str::ToStr;
 pub use clone::Clone;
 
@@ -122,6 +122,9 @@ pub mod linkhack {
     }
 }
 
+// Internal macros
+mod macros;
+
 /* The Prelude. */
 
 pub mod prelude;
@@ -261,12 +264,3 @@ mod core {
     pub use sys;
     pub use pipes;
 }
-
-
-// Local Variables:
-// mode: rust;
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
diff --git a/src/libcore/either.rs b/src/libcore/either.rs
index 92f850cddd6..33b7e81ee85 100644
--- a/src/libcore/either.rs
+++ b/src/libcore/either.rs
@@ -263,13 +263,3 @@ fn test_partition_empty() {
     assert_eq!(vec::len(lefts), 0u);
     assert_eq!(vec::len(rights), 0u);
 }
-
-//
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
-//
diff --git a/src/libcore/hashmap.rs b/src/libcore/hashmap.rs
index 8ed54741f12..9b01c1dad06 100644
--- a/src/libcore/hashmap.rs
+++ b/src/libcore/hashmap.rs
@@ -678,7 +678,7 @@ pub impl <T:Hash + Eq> HashSet<T> {
     }
 }
 
-#[test]
+#[cfg(test)]
 mod test_map {
     use container::{Container, Map, Set};
     use option::{None, Some};
@@ -854,7 +854,7 @@ mod test_map {
     }
 }
 
-#[test]
+#[cfg(test)]
 mod test_set {
     use super::*;
     use container::{Container, Map, Set};
diff --git a/src/libcore/io.rs b/src/libcore/io.rs
index 217ea1a9982..460fd60d4c5 100644
--- a/src/libcore/io.rs
+++ b/src/libcore/io.rs
@@ -1954,13 +1954,3 @@ mod tests {
         }
     }
 }
-
-//
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
-//
diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs
index 7476531ef94..8fc2db6d6f1 100644
--- a/src/libcore/iter.rs
+++ b/src/libcore/iter.rs
@@ -41,6 +41,9 @@ much easier to implement.
 
 */
 
+use cmp::Ord;
+use option::{Option, Some, None};
+
 pub trait Times {
     fn times(&self, it: &fn() -> bool);
 }
@@ -104,6 +107,78 @@ pub fn all<T>(predicate: &fn(T) -> bool, iter: &fn(f: &fn(T) -> bool)) -> bool {
     true
 }
 
+/**
+ * Return the first element where `predicate` returns `true`. Return `None` if no element is found.
+ *
+ * # Example:
+ *
+ * ~~~~
+ * let xs = ~[1u, 2, 3, 4, 5, 6];
+ * assert_eq!(*find(|& &x: & &uint| x > 3, |f| xs.each(f)).unwrap(), 4);
+ * ~~~~
+ */
+#[inline(always)]
+pub fn find<T>(predicate: &fn(&T) -> bool, iter: &fn(f: &fn(T) -> bool)) -> Option<T> {
+    for iter |x| {
+        if predicate(&x) {
+            return Some(x);
+        }
+    }
+    None
+}
+
+/**
+ * Return the largest item yielded by an iterator. Return `None` if the iterator is empty.
+ *
+ * # Example:
+ *
+ * ~~~~
+ * let xs = ~[8, 2, 3, 1, -5, 9, 11, 15];
+ * assert_eq!(max(|f| xs.each(f)).unwrap(), &15);
+ * ~~~~
+ */
+#[inline]
+pub fn max<T: Ord>(iter: &fn(f: &fn(T) -> bool)) -> Option<T> {
+    let mut result = None;
+    for iter |x| {
+        match result {
+            Some(ref mut y) => {
+                if x > *y {
+                    *y = x;
+                }
+            }
+            None => result = Some(x)
+        }
+    }
+    result
+}
+
+/**
+ * Return the smallest item yielded by an iterator. Return `None` if the iterator is empty.
+ *
+ * # Example:
+ *
+ * ~~~~
+ * let xs = ~[8, 2, 3, 1, -5, 9, 11, 15];
+ * assert_eq!(max(|f| xs.each(f)).unwrap(), &-5);
+ * ~~~~
+ */
+#[inline]
+pub fn min<T: Ord>(iter: &fn(f: &fn(T) -> bool)) -> Option<T> {
+    let mut result = None;
+    for iter |x| {
+        match result {
+            Some(ref mut y) => {
+                if x < *y {
+                    *y = x;
+                }
+            }
+            None => result = Some(x)
+        }
+    }
+    result
+}
+
 #[cfg(test)]
 mod tests {
     use super::*;
@@ -128,4 +203,22 @@ mod tests {
         assert!(all(|x: uint| x < 6, |f| uint::range(1, 6, f)));
         assert!(!all(|x: uint| x < 5, |f| uint::range(1, 6, f)));
     }
+
+    #[test]
+    fn test_find() {
+        let xs = ~[1u, 2, 3, 4, 5, 6];
+        assert_eq!(*find(|& &x: & &uint| x > 3, |f| xs.each(f)).unwrap(), 4);
+    }
+
+    #[test]
+    fn test_max() {
+        let xs = ~[8, 2, 3, 1, -5, 9, 11, 15];
+        assert_eq!(max(|f| xs.each(f)).unwrap(), &15);
+    }
+
+    #[test]
+    fn test_min() {
+        let xs = ~[8, 2, 3, 1, -5, 9, 11, 15];
+        assert_eq!(min(|f| xs.each(f)).unwrap(), &-5);
+    }
 }
diff --git a/src/libcore/iterator.rs b/src/libcore/iterator.rs
index 8bbf8430858..5e95485b273 100644
--- a/src/libcore/iterator.rs
+++ b/src/libcore/iterator.rs
@@ -29,7 +29,7 @@ pub trait Iterator<A> {
 ///
 /// In the future these will be default methods instead of a utility trait.
 pub trait IteratorUtil<A> {
-    fn chain(self, other: Self) -> ChainIterator<Self>;
+    fn chain<U: Iterator<A>>(self, other: U) -> ChainIterator<Self, U>;
     fn zip<B, U: Iterator<B>>(self, other: U) -> ZipIterator<Self, U>;
     // FIXME: #5898: should be called map
     fn transform<'r, B>(self, f: &'r fn(A) -> B) -> MapIterator<'r, A, B, Self>;
@@ -50,7 +50,7 @@ pub trait IteratorUtil<A> {
 /// In the future these will be default methods instead of a utility trait.
 impl<A, T: Iterator<A>> IteratorUtil<A> for T {
     #[inline(always)]
-    fn chain(self, other: T) -> ChainIterator<T> {
+    fn chain<U: Iterator<A>>(self, other: U) -> ChainIterator<T, U> {
         ChainIterator{a: self, b: other, flag: false}
     }
 
@@ -115,13 +115,13 @@ impl<A, T: Iterator<A>> IteratorUtil<A> for T {
     }
 }
 
-pub struct ChainIterator<T> {
+pub struct ChainIterator<T, U> {
     priv a: T,
-    priv b: T,
+    priv b: U,
     priv flag: bool
 }
 
-impl<A, T: Iterator<A>> Iterator<A> for ChainIterator<T> {
+impl<A, T: Iterator<A>, U: Iterator<A>> Iterator<A> for ChainIterator<T, U> {
     #[inline]
     fn next(&mut self) -> Option<A> {
         if self.flag {
@@ -385,7 +385,7 @@ mod tests {
     #[test]
     fn test_iterator_chain() {
         let xs = [0u, 1, 2, 3, 4, 5];
-        let ys = [30, 40, 50, 60];
+        let ys = [30u, 40, 50, 60];
         let expected = [0, 1, 2, 3, 4, 5, 30, 40, 50, 60];
         let mut it = xs.iter().chain(ys.iter());
         let mut i = 0;
@@ -394,6 +394,15 @@ mod tests {
             i += 1;
         }
         assert_eq!(i, expected.len());
+
+        let ys = Counter::new(30u, 10).take(4);
+        let mut it = xs.iter().transform(|&x| x).chain(ys);
+        let mut i = 0;
+        for it.advance |x: uint| {
+            assert_eq!(x, expected[i]);
+            i += 1;
+        }
+        assert_eq!(i, expected.len());
     }
 
     #[test]
diff --git a/src/libcore/libc.rs b/src/libcore/libc.rs
index d7a9ab4d63b..6fb4572913d 100644
--- a/src/libcore/libc.rs
+++ b/src/libcore/libc.rs
@@ -104,6 +104,7 @@ pub use libc::funcs::posix88::unistd::*;
 
 pub use libc::funcs::posix01::stat_::*;
 pub use libc::funcs::posix01::unistd::*;
+pub use libc::funcs::posix01::glob::*;
 pub use libc::funcs::posix08::unistd::*;
 
 pub use libc::funcs::bsd44::*;
@@ -210,7 +211,21 @@ pub mod types {
     #[cfg(target_os = "android")]
     pub mod os {
         pub mod common {
-            pub mod posix01 {}
+            pub mod posix01 {
+                use libc::types::common::c95::{c_void};
+                use libc::types::os::arch::c95::{c_char, size_t};
+                pub struct glob_t {
+                    gl_pathc: size_t,
+                    gl_pathv: **c_char,
+                    gl_offs:  size_t,
+
+                    __unused1: *c_void,
+                    __unused2: *c_void,
+                    __unused3: *c_void,
+                    __unused4: *c_void,
+                    __unused5: *c_void,
+                }
+            }
         }
 
         #[cfg(target_arch = "x86")]
@@ -368,7 +383,25 @@ pub mod types {
     #[cfg(target_os = "freebsd")]
     pub mod os {
         pub mod common {
-            pub mod posix01 {}
+            pub mod posix01 {
+                use libc::types::common::c95::{c_void};
+                use libc::types::os::arch::c95::{c_char, c_int, size_t};
+                pub struct glob_t {
+                    gl_pathc:  size_t,
+                    __unused1: size_t,
+                    gl_offs:   size_t,
+                    __unused2: c_int,
+                    gl_pathv:  **c_char,
+
+                    __unused3: *c_void,
+
+                    __unused4: *c_void,
+                    __unused5: *c_void,
+                    __unused6: *c_void,
+                    __unused7: *c_void,
+                    __unused8: *c_void,
+                }
+            }
         }
 
         #[cfg(target_arch = "x86_64")]
@@ -548,12 +581,16 @@ pub mod types {
 
                 pub type LPWSTR = *mut WCHAR;
                 pub type LPSTR = *mut CHAR;
+                pub type LPTSTR = *mut CHAR;
 
                 // Not really, but opaque to us.
                 pub type LPSECURITY_ATTRIBUTES = LPVOID;
 
                 pub type LPVOID = *mut c_void;
+                pub type LPBYTE = *mut BYTE;
                 pub type LPWORD = *mut WORD;
+                pub type LPDWORD = *mut DWORD;
+                pub type LPHANDLE = *mut HANDLE;
 
                 pub type LRESULT = LONG_PTR;
                 pub type PBOOL = *mut BOOL;
@@ -562,6 +599,36 @@ pub mod types {
 
                 pub type time64_t = i64;
                 pub type int64 = i64;
+
+                pub struct STARTUPINFO {
+                    cb: DWORD,
+                    lpReserved: LPTSTR,
+                    lpDesktop: LPTSTR,
+                    lpTitle: LPTSTR,
+                    dwX: DWORD,
+                    dwY: DWORD,
+                    dwXSize: DWORD,
+                    dwYSize: DWORD,
+                    dwXCountChars: DWORD,
+                    dwYCountCharts: DWORD,
+                    dwFillAttribute: DWORD,
+                    dwFlags: DWORD,
+                    wShowWindow: WORD,
+                    cbReserved2: WORD,
+                    lpReserved2: LPBYTE,
+                    hStdInput: HANDLE,
+                    hStdOutput: HANDLE,
+                    hStdError: HANDLE
+                }
+                pub type LPSTARTUPINFO = *mut STARTUPINFO;
+
+                pub struct PROCESS_INFORMATION {
+                    hProcess: HANDLE,
+                    hThread: HANDLE,
+                    dwProcessId: DWORD,
+                    dwThreadId: DWORD
+                }
+                pub type LPPROCESS_INFORMATION = *mut PROCESS_INFORMATION;
             }
         }
     }
@@ -570,6 +637,23 @@ pub mod types {
     pub mod os {
         pub mod common {
             pub mod posix01 {
+                use libc::types::common::c95::{c_void};
+                use libc::types::os::arch::c95::{c_char, c_int, size_t};
+                pub struct glob_t {
+                    gl_pathc:  size_t,
+                    __unused1: c_int,
+                    gl_offs:   size_t,
+                    __unused2: c_int,
+                    gl_pathv:  **c_char,
+
+                    __unused3: *c_void,
+
+                    __unused4: *c_void,
+                    __unused5: *c_void,
+                    __unused6: *c_void,
+                    __unused7: *c_void,
+                    __unused8: *c_void,
+                }
             }
         }
 
@@ -797,6 +881,11 @@ pub mod consts {
         pub mod bsd44 {
         }
         pub mod extra {
+            use libc::types::os::arch::extra::{DWORD, BOOL};
+
+            pub static TRUE : BOOL = 1;
+            pub static FALSE : BOOL = 0;
+
             pub static O_TEXT : int = 16384;
             pub static O_BINARY : int = 32768;
             pub static O_NOINHERIT: int = 128;
@@ -804,6 +893,50 @@ pub mod consts {
             pub static ERROR_SUCCESS : int = 0;
             pub static ERROR_INSUFFICIENT_BUFFER : int = 122;
             pub static INVALID_HANDLE_VALUE: int = -1;
+
+            pub static DELETE : DWORD = 0x00010000;
+            pub static READ_CONTROL : DWORD = 0x00020000;
+            pub static SYNCHRONIZE : DWORD = 0x00100000;
+            pub static WRITE_DAC : DWORD = 0x00040000;
+            pub static WRITE_OWNER : DWORD = 0x00080000;
+
+            pub static PROCESS_CREATE_PROCESS : DWORD = 0x0080;
+            pub static PROCESS_CREATE_THREAD : DWORD = 0x0002;
+            pub static PROCESS_DUP_HANDLE : DWORD = 0x0040;
+            pub static PROCESS_QUERY_INFORMATION : DWORD = 0x0400;
+            pub static PROCESS_QUERY_LIMITED_INFORMATION : DWORD = 0x1000;
+            pub static PROCESS_SET_INFORMATION : DWORD = 0x0200;
+            pub static PROCESS_SET_QUOTA : DWORD = 0x0100;
+            pub static PROCESS_SUSPEND_RESUME : DWORD = 0x0800;
+            pub static PROCESS_TERMINATE : DWORD = 0x0001;
+            pub static PROCESS_VM_OPERATION : DWORD = 0x0008;
+            pub static PROCESS_VM_READ : DWORD = 0x0010;
+            pub static PROCESS_VM_WRITE : DWORD = 0x0020;
+
+            pub static STARTF_FORCEONFEEDBACK : DWORD = 0x00000040;
+            pub static STARTF_FORCEOFFFEEDBACK : DWORD = 0x00000080;
+            pub static STARTF_PREVENTPINNING : DWORD = 0x00002000;
+            pub static STARTF_RUNFULLSCREEN : DWORD = 0x00000020;
+            pub static STARTF_TITLEISAPPID : DWORD = 0x00001000;
+            pub static STARTF_TITLEISLINKNAME : DWORD = 0x00000800;
+            pub static STARTF_USECOUNTCHARS : DWORD = 0x00000008;
+            pub static STARTF_USEFILLATTRIBUTE : DWORD = 0x00000010;
+            pub static STARTF_USEHOTKEY : DWORD = 0x00000200;
+            pub static STARTF_USEPOSITION : DWORD = 0x00000004;
+            pub static STARTF_USESHOWWINDOW : DWORD = 0x00000001;
+            pub static STARTF_USESIZE : DWORD = 0x00000002;
+            pub static STARTF_USESTDHANDLES : DWORD = 0x00000100;
+
+            pub static WAIT_ABANDONED : DWORD = 0x00000080;
+            pub static WAIT_OBJECT_0 : DWORD = 0x00000000;
+            pub static WAIT_TIMEOUT : DWORD = 0x00000102;
+            pub static WAIT_FAILED : DWORD = -1;
+
+            pub static DUPLICATE_CLOSE_SOURCE : DWORD = 0x00000001;
+            pub static DUPLICATE_SAME_ACCESS : DWORD = 0x00000002;
+
+            pub static INFINITE : DWORD = -1;
+            pub static STILL_ACTIVE : DWORD = 259;
         }
     }
 
@@ -876,6 +1009,18 @@ pub mod consts {
         }
         pub mod posix01 {
             pub static SIGTRAP : int = 5;
+
+            pub static GLOB_ERR      : int = 1 << 0;
+            pub static GLOB_MARK     : int = 1 << 1;
+            pub static GLOB_NOSORT   : int = 1 << 2;
+            pub static GLOB_DOOFFS   : int = 1 << 3;
+            pub static GLOB_NOCHECK  : int = 1 << 4;
+            pub static GLOB_APPEND   : int = 1 << 5;
+            pub static GLOB_NOESCAPE : int = 1 << 6;
+
+            pub static GLOB_NOSPACE  : int = 1;
+            pub static GLOB_ABORTED  : int = 2;
+            pub static GLOB_NOMATCH  : int = 3;
         }
         pub mod posix08 {
         }
@@ -955,6 +1100,18 @@ pub mod consts {
         }
         pub mod posix01 {
             pub static SIGTRAP : int = 5;
+
+            pub static GLOB_APPEND   : int = 0x0001;
+            pub static GLOB_DOOFFS   : int = 0x0002;
+            pub static GLOB_ERR      : int = 0x0004;
+            pub static GLOB_MARK     : int = 0x0008;
+            pub static GLOB_NOCHECK  : int = 0x0010;
+            pub static GLOB_NOSORT   : int = 0x0020;
+            pub static GLOB_NOESCAPE : int = 0x2000;
+
+            pub static GLOB_NOSPACE  : int = -1;
+            pub static GLOB_ABORTED  : int = -2;
+            pub static GLOB_NOMATCH  : int = -3;
         }
         pub mod posix08 {
         }
@@ -1035,6 +1192,18 @@ pub mod consts {
         }
         pub mod posix01 {
             pub static SIGTRAP : int = 5;
+
+            pub static GLOB_APPEND   : int = 0x0001;
+            pub static GLOB_DOOFFS   : int = 0x0002;
+            pub static GLOB_ERR      : int = 0x0004;
+            pub static GLOB_MARK     : int = 0x0008;
+            pub static GLOB_NOCHECK  : int = 0x0010;
+            pub static GLOB_NOSORT   : int = 0x0020;
+            pub static GLOB_NOESCAPE : int = 0x2000;
+
+            pub static GLOB_NOSPACE  : int = -1;
+            pub static GLOB_ABORTED  : int = -2;
+            pub static GLOB_NOMATCH  : int = -3;
         }
         pub mod posix08 {
         }
@@ -1605,6 +1774,21 @@ pub mod funcs {
                                -> pid_t;
             }
         }
+
+        #[nolink]
+        #[abi = "cdecl"]
+        pub mod glob {
+            use libc::types::common::c95::{c_void};
+            use libc::types::os::arch::c95::{c_char, c_int};
+            use libc::types::os::common::posix01::{glob_t};
+
+            pub extern {
+                unsafe fn glob(pattern: *c_char, flags: c_int,
+                               errfunc: *c_void, // XXX callback
+                               pglob: *mut glob_t);
+                unsafe fn globfree(pglob: *mut glob_t);
+            }
+        }
     }
 
     #[cfg(target_os = "win32")]
@@ -1614,6 +1798,9 @@ pub mod funcs {
 
         pub mod unistd {
         }
+
+        pub mod glob {
+        }
     }
 
 
@@ -1646,12 +1833,24 @@ pub mod funcs {
 
             unsafe fn sysctlnametomib(name: *c_char, mibp: *mut c_int,
                                sizep: *mut size_t) -> c_int;
+
+            unsafe fn getdtablesize() -> c_int;
         }
     }
 
 
     #[cfg(target_os = "linux")]
     #[cfg(target_os = "android")]
+    pub mod bsd44 {
+        use libc::types::os::arch::c95::{c_int};
+
+        #[abi = "cdecl"]
+        pub extern {
+            unsafe fn getdtablesize() -> c_int;
+        }
+    }
+
+
     #[cfg(target_os = "win32")]
     pub mod bsd44 {
     }
@@ -1685,9 +1884,11 @@ pub mod funcs {
         pub mod kernel32 {
             use libc::types::os::arch::c95::{c_uint};
             use libc::types::os::arch::extra::{BOOL, DWORD, HMODULE};
-            use libc::types::os::arch::extra::{LPCWSTR, LPWSTR, LPTCH};
-            use libc::types::os::arch::extra::{LPSECURITY_ATTRIBUTES};
-            use libc::types::os::arch::extra::{HANDLE};
+            use libc::types::os::arch::extra::{LPCWSTR, LPWSTR, LPCTSTR,
+                                               LPTSTR, LPTCH, LPDWORD, LPVOID};
+            use libc::types::os::arch::extra::{LPSECURITY_ATTRIBUTES, LPSTARTUPINFO,
+                                               LPPROCESS_INFORMATION};
+            use libc::types::os::arch::extra::{HANDLE, LPHANDLE};
 
             #[abi = "stdcall"]
             pub extern "stdcall" {
@@ -1724,29 +1925,46 @@ pub mod funcs {
                                        findFileData: HANDLE)
                     -> BOOL;
                 unsafe fn FindClose(findFile: HANDLE) -> BOOL;
+                unsafe fn DuplicateHandle(hSourceProcessHandle: HANDLE,
+                                          hSourceHandle: HANDLE,
+                                          hTargetProcessHandle: HANDLE,
+                                          lpTargetHandle: LPHANDLE,
+                                          dwDesiredAccess: DWORD,
+                                          bInheritHandle: BOOL,
+                                          dwOptions: DWORD) -> BOOL;
                 unsafe fn CloseHandle(hObject: HANDLE) -> BOOL;
+                unsafe fn OpenProcess(dwDesiredAccess: DWORD,
+                                      bInheritHandle: BOOL,
+                                      dwProcessId: DWORD) -> HANDLE;
+                unsafe fn GetCurrentProcess() -> HANDLE;
+                unsafe fn CreateProcessA(lpApplicationName: LPCTSTR,
+                                         lpCommandLine: LPTSTR,
+                                         lpProcessAttributes: LPSECURITY_ATTRIBUTES,
+                                         lpThreadAttributes: LPSECURITY_ATTRIBUTES,
+                                         bInheritHandles: BOOL,
+                                         dwCreationFlags: DWORD,
+                                         lpEnvironment: LPVOID,
+                                         lpCurrentDirectory: LPCTSTR,
+                                         lpStartupInfo: LPSTARTUPINFO,
+                                         lpProcessInformation: LPPROCESS_INFORMATION) -> BOOL;
+                unsafe fn WaitForSingleObject(hHandle: HANDLE, dwMilliseconds: DWORD) -> DWORD;
                 unsafe fn TerminateProcess(hProcess: HANDLE, uExitCode: c_uint) -> BOOL;
+                unsafe fn GetExitCodeProcess(hProcess: HANDLE, lpExitCode: LPDWORD) -> BOOL;
             }
         }
 
         pub mod msvcrt {
-            use libc::types::os::arch::c95::c_int;
+            use libc::types::os::arch::c95::{c_int, c_long};
 
             #[abi = "cdecl"]
             #[nolink]
             pub extern {
                 #[link_name = "_commit"]
                 unsafe fn commit(fd: c_int) -> c_int;
+
+                #[link_name = "_get_osfhandle"]
+                unsafe fn get_osfhandle(fd: c_int) -> c_long;
             }
         }
     }
 }
-
-
-// Local Variables:
-// mode: rust;
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
diff --git a/src/libcore/logging.rs b/src/libcore/logging.rs
index ba976de50ab..afe8338f2ce 100644
--- a/src/libcore/logging.rs
+++ b/src/libcore/logging.rs
@@ -59,4 +59,3 @@ pub fn log_type<T>(level: u32, object: &T) {
         rustrt::rust_log_str(level, transmute(vec::raw::to_ptr(bytes)), len);
     }
 }
-
diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs
new file mode 100644
index 00000000000..b19a753b715
--- /dev/null
+++ b/src/libcore/macros.rs
@@ -0,0 +1,39 @@
+// 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.
+
+#[macro_escape];
+
+// Some basic logging
+macro_rules! rtdebug_ (
+    ($( $arg:expr),+) => ( {
+        dumb_println(fmt!( $($arg),+ ));
+
+        fn dumb_println(s: &str) {
+            use io::WriterUtil;
+            let dbg = ::libc::STDERR_FILENO as ::io::fd_t;
+            dbg.write_str(s);
+            dbg.write_str("\n");
+        }
+
+    } )
+)
+
+// An alternate version with no output, for turning off logging
+macro_rules! rtdebug (
+    ($( $arg:expr),+) => ( $(let _ = $arg)*; )
+)
+
+macro_rules! abort(
+    ($( $msg:expr),+) => ( {
+        rtdebug!($($msg),+);
+
+        unsafe { ::libc::abort(); }
+    } )
+)
diff --git a/src/libcore/num/cmath.rs b/src/libcore/num/cmath.rs
index 30b0c54dc2d..8a0a88235d2 100644
--- a/src/libcore/num/cmath.rs
+++ b/src/libcore/num/cmath.rs
@@ -267,14 +267,3 @@ pub mod c_double_targ_consts {
 }
 
 */
-
-//
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
-//
-
diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs
index 6398127a5fa..416ec2069b5 100644
--- a/src/libcore/num/f32.rs
+++ b/src/libcore/num/f32.rs
@@ -10,7 +10,6 @@
 
 //! Operations and constants for `f32`
 
-use from_str;
 use num::{Zero, One, strconv};
 use prelude::*;
 
@@ -123,7 +122,7 @@ pub fn sub(x: f32, y: f32) -> f32 { return x - y; }
 pub fn mul(x: f32, y: f32) -> f32 { return x * y; }
 
 #[inline(always)]
-pub fn quot(x: f32, y: f32) -> f32 { return x / y; }
+pub fn div(x: f32, y: f32) -> f32 { return x / y; }
 
 #[inline(always)]
 pub fn rem(x: f32, y: f32) -> f32 { return x % y; }
@@ -278,11 +277,13 @@ impl Mul<f32,f32> for f32 {
     #[inline(always)]
     fn mul(&self, other: &f32) -> f32 { *self * *other }
 }
+
 #[cfg(notest)]
-impl Quot<f32,f32> for f32 {
+impl Div<f32,f32> for f32 {
     #[inline(always)]
-    fn quot(&self, other: &f32) -> f32 { *self / *other }
+    fn div(&self, other: &f32) -> f32 { *self / *other }
 }
+
 #[cfg(notest)]
 impl Rem<f32,f32> for f32 {
     #[inline(always)]
@@ -791,7 +792,7 @@ pub fn from_str_radix(num: &str, rdx: uint) -> Option<f32> {
                              strconv::ExpNone, false, false)
 }
 
-impl from_str::FromStr for f32 {
+impl FromStr for f32 {
     #[inline(always)]
     fn from_str(val: &str) -> Option<f32> { from_str(val) }
 }
@@ -979,13 +980,3 @@ mod tests {
         assert_eq!(Primitive::bytes::<f32>(), sys::size_of::<f32>());
     }
 }
-
-//
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
-//
diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs
index 013f3c5095e..6e09ca61a7d 100644
--- a/src/libcore/num/f64.rs
+++ b/src/libcore/num/f64.rs
@@ -10,7 +10,6 @@
 
 //! Operations and constants for `f64`
 
-use from_str;
 use libc::c_int;
 use num::{Zero, One, strconv};
 use prelude::*;
@@ -149,7 +148,7 @@ pub fn sub(x: f64, y: f64) -> f64 { return x - y; }
 pub fn mul(x: f64, y: f64) -> f64 { return x * y; }
 
 #[inline(always)]
-pub fn quot(x: f64, y: f64) -> f64 { return x / y; }
+pub fn div(x: f64, y: f64) -> f64 { return x / y; }
 
 #[inline(always)]
 pub fn rem(x: f64, y: f64) -> f64 { return x % y; }
@@ -297,9 +296,8 @@ impl Mul<f64,f64> for f64 {
     fn mul(&self, other: &f64) -> f64 { *self * *other }
 }
 #[cfg(notest)]
-impl Quot<f64,f64> for f64 {
-    #[inline(always)]
-    fn quot(&self, other: &f64) -> f64 { *self / *other }
+impl Div<f64,f64> for f64 {
+    fn div(&self, other: &f64) -> f64 { *self / *other }
 }
 #[cfg(notest)]
 impl Rem<f64,f64> for f64 {
@@ -837,7 +835,7 @@ pub fn from_str_radix(num: &str, rdx: uint) -> Option<f64> {
                              strconv::ExpNone, false, false)
 }
 
-impl from_str::FromStr for f64 {
+impl FromStr for f64 {
     #[inline(always)]
     fn from_str(val: &str) -> Option<f64> { from_str(val) }
 }
@@ -1030,13 +1028,3 @@ mod tests {
         assert_eq!(Primitive::bytes::<f64>(), sys::size_of::<f64>());
     }
 }
-
-//
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
-//
diff --git a/src/libcore/num/float.rs b/src/libcore/num/float.rs
index 496ad4ec176..da9d03f6a7b 100644
--- a/src/libcore/num/float.rs
+++ b/src/libcore/num/float.rs
@@ -20,12 +20,11 @@
 
 // PORT this must match in width according to architecture
 
-use from_str;
 use libc::c_int;
 use num::{Zero, One, strconv};
 use prelude::*;
 
-pub use f64::{add, sub, mul, quot, rem, lt, le, eq, ne, ge, gt};
+pub use f64::{add, sub, mul, div, rem, lt, le, eq, ne, ge, gt};
 pub use f64::logarithm;
 pub use f64::{acos, asin, atan2, cbrt, ceil, copysign, cosh, floor};
 pub use f64::{erf, erfc, exp, expm1, exp2, abs_sub};
@@ -289,7 +288,7 @@ pub fn from_str_radix(num: &str, radix: uint) -> Option<float> {
                              strconv::ExpNone, false, false)
 }
 
-impl from_str::FromStr for float {
+impl FromStr for float {
     #[inline(always)]
     fn from_str(val: &str) -> Option<float> { from_str(val) }
 }
@@ -691,11 +690,13 @@ impl Mul<float,float> for float {
     #[inline(always)]
     fn mul(&self, other: &float) -> float { *self * *other }
 }
+
 #[cfg(notest)]
-impl Quot<float,float> for float {
+impl Div<float,float> for float {
     #[inline(always)]
-    fn quot(&self, other: &float) -> float { *self / *other }
+    fn div(&self, other: &float) -> float { *self / *other }
 }
+
 #[cfg(notest)]
 impl Rem<float,float> for float {
     #[inline(always)]
@@ -1132,13 +1133,3 @@ mod tests {
         assert_eq!(to_str_digits(-infinity, 10u), ~"-inf");
     }
 }
-
-//
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
-//
diff --git a/src/libcore/num/int-template.rs b/src/libcore/num/int-template.rs
index 77b4eab1338..95c187a7be2 100644
--- a/src/libcore/num/int-template.rs
+++ b/src/libcore/num/int-template.rs
@@ -10,7 +10,6 @@
 
 use T = self::inst::T;
 
-use from_str::FromStr;
 use num::{ToStrRadix, FromStrRadix};
 use num::{Zero, One, strconv};
 use prelude::*;
@@ -30,7 +29,7 @@ pub fn sub(x: T, y: T) -> T { x - y }
 #[inline(always)]
 pub fn mul(x: T, y: T) -> T { x * y }
 #[inline(always)]
-pub fn quot(x: T, y: T) -> T { x / y }
+pub fn div(x: T, y: T) -> T { x / y }
 
 ///
 /// Returns the remainder of y / x.
@@ -202,10 +201,10 @@ impl Mul<T,T> for T {
 }
 
 #[cfg(notest)]
-impl Quot<T,T> for T {
+impl Div<T,T> for T {
     ///
-    /// Returns the integer quotient, truncated towards 0. As this behaviour reflects
-    /// the underlying machine implementation it is more efficient than `Natural::div`.
+    /// Integer division, truncated towards 0. As this behaviour reflects the underlying
+    /// machine implementation it is more efficient than `Integer::div_floor`.
     ///
     /// # Examples
     ///
@@ -222,7 +221,7 @@ impl Quot<T,T> for T {
     /// ~~~
     ///
     #[inline(always)]
-    fn quot(&self, other: &T) -> T { *self / *other }
+    fn div(&self, other: &T) -> T { *self / *other }
 }
 
 #[cfg(notest)]
@@ -297,25 +296,25 @@ impl Integer for T {
     /// # Examples
     ///
     /// ~~~
-    /// assert!(( 8).div( 3) ==  2);
-    /// assert!(( 8).div(-3) == -3);
-    /// assert!((-8).div( 3) == -3);
-    /// assert!((-8).div(-3) ==  2);
+    /// assert!(( 8).div_floor( 3) ==  2);
+    /// assert!(( 8).div_floor(-3) == -3);
+    /// assert!((-8).div_floor( 3) == -3);
+    /// assert!((-8).div_floor(-3) ==  2);
     ///
-    /// assert!(( 1).div( 2) ==  0);
-    /// assert!(( 1).div(-2) == -1);
-    /// assert!((-1).div( 2) == -1);
-    /// assert!((-1).div(-2) ==  0);
+    /// assert!(( 1).div_floor( 2) ==  0);
+    /// assert!(( 1).div_floor(-2) == -1);
+    /// assert!((-1).div_floor( 2) == -1);
+    /// assert!((-1).div_floor(-2) ==  0);
     /// ~~~
     ///
     #[inline(always)]
-    fn div(&self, other: &T) -> T {
+    fn div_floor(&self, other: &T) -> T {
         // Algorithm from [Daan Leijen. _Division and Modulus for Computer Scientists_,
         // December 2001](http://research.microsoft.com/pubs/151917/divmodnote-letter.pdf)
-        match self.quot_rem(other) {
-            (q, r) if (r > 0 && *other < 0)
-                   || (r < 0 && *other > 0) => q - 1,
-            (q, _)                          => q,
+        match self.div_rem(other) {
+            (d, r) if (r > 0 && *other < 0)
+                   || (r < 0 && *other > 0) => d - 1,
+            (d, _)                          => d,
         }
     }
 
@@ -323,25 +322,25 @@ impl Integer for T {
     /// Integer modulo, satisfying:
     ///
     /// ~~~
-    /// assert!(n.div(d) * d + n.modulo(d) == n)
+    /// assert!(n.div_floor(d) * d + n.mod_floor(d) == n)
     /// ~~~
     ///
     /// # Examples
     ///
     /// ~~~
-    /// assert!(( 8).modulo( 3) ==  2);
-    /// assert!(( 8).modulo(-3) == -1);
-    /// assert!((-8).modulo( 3) ==  1);
-    /// assert!((-8).modulo(-3) == -2);
+    /// assert!(( 8).mod_floor( 3) ==  2);
+    /// assert!(( 8).mod_floor(-3) == -1);
+    /// assert!((-8).mod_floor( 3) ==  1);
+    /// assert!((-8).mod_floor(-3) == -2);
     ///
-    /// assert!(( 1).modulo( 2) ==  1);
-    /// assert!(( 1).modulo(-2) == -1);
-    /// assert!((-1).modulo( 2) ==  1);
-    /// assert!((-1).modulo(-2) == -1);
+    /// assert!(( 1).mod_floor( 2) ==  1);
+    /// assert!(( 1).mod_floor(-2) == -1);
+    /// assert!((-1).mod_floor( 2) ==  1);
+    /// assert!((-1).mod_floor(-2) == -1);
     /// ~~~
     ///
     #[inline(always)]
-    fn modulo(&self, other: &T) -> T {
+    fn mod_floor(&self, other: &T) -> T {
         // Algorithm from [Daan Leijen. _Division and Modulus for Computer Scientists_,
         // December 2001](http://research.microsoft.com/pubs/151917/divmodnote-letter.pdf)
         match *self % *other {
@@ -351,21 +350,21 @@ impl Integer for T {
         }
     }
 
-    /// Calculates `div` and `modulo` simultaneously
+    /// Calculates `div_floor` and `mod_floor` simultaneously
     #[inline(always)]
-    fn div_mod(&self, other: &T) -> (T,T) {
+    fn div_mod_floor(&self, other: &T) -> (T,T) {
         // Algorithm from [Daan Leijen. _Division and Modulus for Computer Scientists_,
         // December 2001](http://research.microsoft.com/pubs/151917/divmodnote-letter.pdf)
-        match self.quot_rem(other) {
-            (q, r) if (r > 0 && *other < 0)
-                   || (r < 0 && *other > 0) => (q - 1, r + *other),
-            (q, r)                          => (q, r),
+        match self.div_rem(other) {
+            (d, r) if (r > 0 && *other < 0)
+                   || (r < 0 && *other > 0) => (d - 1, r + *other),
+            (d, r)                          => (d, r),
         }
     }
 
-    /// Calculates `quot` (`\`) and `rem` (`%`) simultaneously
+    /// Calculates `div` (`\`) and `rem` (`%`) simultaneously
     #[inline(always)]
-    fn quot_rem(&self, other: &T) -> (T,T) {
+    fn div_rem(&self, other: &T) -> (T,T) {
         (*self / *other, *self % *other)
     }
 
@@ -589,42 +588,42 @@ mod tests {
     }
 
     #[test]
-    fn test_quot_rem() {
-        fn test_nd_qr(nd: (T,T), qr: (T,T)) {
+    fn test_div_rem() {
+        fn test_nd_dr(nd: (T,T), qr: (T,T)) {
             let (n,d) = nd;
-            let separate_quot_rem = (n / d, n % d);
-            let combined_quot_rem = n.quot_rem(&d);
+            let separate_div_rem = (n / d, n % d);
+            let combined_div_rem = n.div_rem(&d);
 
-            assert_eq!(separate_quot_rem, qr);
-            assert_eq!(combined_quot_rem, qr);
+            assert_eq!(separate_div_rem, qr);
+            assert_eq!(combined_div_rem, qr);
 
-            test_division_rule(nd, separate_quot_rem);
-            test_division_rule(nd, combined_quot_rem);
+            test_division_rule(nd, separate_div_rem);
+            test_division_rule(nd, combined_div_rem);
         }
 
-        test_nd_qr(( 8,  3), ( 2,  2));
-        test_nd_qr(( 8, -3), (-2,  2));
-        test_nd_qr((-8,  3), (-2, -2));
-        test_nd_qr((-8, -3), ( 2, -2));
+        test_nd_dr(( 8,  3), ( 2,  2));
+        test_nd_dr(( 8, -3), (-2,  2));
+        test_nd_dr((-8,  3), (-2, -2));
+        test_nd_dr((-8, -3), ( 2, -2));
 
-        test_nd_qr(( 1,  2), ( 0,  1));
-        test_nd_qr(( 1, -2), ( 0,  1));
-        test_nd_qr((-1,  2), ( 0, -1));
-        test_nd_qr((-1, -2), ( 0, -1));
+        test_nd_dr(( 1,  2), ( 0,  1));
+        test_nd_dr(( 1, -2), ( 0,  1));
+        test_nd_dr((-1,  2), ( 0, -1));
+        test_nd_dr((-1, -2), ( 0, -1));
     }
 
     #[test]
-    fn test_div_mod() {
+    fn test_div_mod_floor() {
         fn test_nd_dm(nd: (T,T), dm: (T,T)) {
             let (n,d) = nd;
-            let separate_div_mod = (n.div(&d), n.modulo(&d));
-            let combined_div_mod = n.div_mod(&d);
+            let separate_div_mod_floor = (n.div_floor(&d), n.mod_floor(&d));
+            let combined_div_mod_floor = n.div_mod_floor(&d);
 
-            assert_eq!(separate_div_mod, dm);
-            assert_eq!(combined_div_mod, dm);
+            assert_eq!(separate_div_mod_floor, dm);
+            assert_eq!(combined_div_mod_floor, dm);
 
-            test_division_rule(nd, separate_div_mod);
-            test_division_rule(nd, combined_div_mod);
+            test_division_rule(nd, separate_div_mod_floor);
+            test_division_rule(nd, combined_div_mod_floor);
         }
 
         test_nd_dm(( 8,  3), ( 2,  2));
diff --git a/src/libcore/num/num.rs b/src/libcore/num/num.rs
index 96fed51309e..1a59a069df7 100644
--- a/src/libcore/num/num.rs
+++ b/src/libcore/num/num.rs
@@ -10,7 +10,7 @@
 
 //! An interface for numeric types
 use cmp::{Eq, Ord};
-use ops::{Add, Sub, Mul, Quot, Rem, Neg};
+use ops::{Add, Sub, Mul, Div, Rem, Neg};
 use ops::{Not, BitAnd, BitOr, BitXor, Shl, Shr};
 use option::Option;
 use kinds::Copy;
@@ -25,7 +25,7 @@ pub trait Num: Eq + Zero + One
              + Add<Self,Self>
              + Sub<Self,Self>
              + Mul<Self,Self>
-             + Quot<Self,Self>
+             + Div<Self,Self>
              + Rem<Self,Self> {}
 
 pub trait IntConvertible {
@@ -69,12 +69,13 @@ pub fn abs<T:Ord + Zero + Neg<T>>(v: T) -> T {
 
 pub trait Integer: Num
                  + Orderable
-                 + Quot<Self,Self>
+                 + Div<Self,Self>
                  + Rem<Self,Self> {
-    fn div(&self, other: &Self) -> Self;
-    fn modulo(&self, other: &Self) -> Self;
-    fn div_mod(&self, other: &Self) -> (Self,Self);
-    fn quot_rem(&self, other: &Self) -> (Self,Self);
+    fn div_rem(&self, other: &Self) -> (Self,Self);
+
+    fn div_floor(&self, other: &Self) -> Self;
+    fn mod_floor(&self, other: &Self) -> Self;
+    fn div_mod_floor(&self, other: &Self) -> (Self,Self);
 
     fn gcd(&self, other: &Self) -> Self;
     fn lcm(&self, other: &Self) -> Self;
@@ -95,7 +96,7 @@ pub trait Round {
 pub trait Fractional: Num
                     + Orderable
                     + Round
-                    + Quot<Self,Self> {
+                    + Div<Self,Self> {
     fn recip(&self) -> Self;
 }
 
@@ -219,7 +220,7 @@ pub trait Primitive: Num
                    + Add<Self,Self>
                    + Sub<Self,Self>
                    + Mul<Self,Self>
-                   + Quot<Self,Self>
+                   + Div<Self,Self>
                    + Rem<Self,Self> {
     // FIXME (#5527): These should be associated constants
     fn bits() -> uint;
@@ -364,7 +365,7 @@ pub trait FromStrRadix {
 /// - If code written to use this function doesn't care about it, it's
 ///   probably assuming that `x^0` always equals `1`.
 ///
-pub fn pow_with_uint<T:NumCast+One+Zero+Copy+Quot<T,T>+Mul<T,T>>(
+pub fn pow_with_uint<T:NumCast+One+Zero+Copy+Div<T,T>+Mul<T,T>>(
     radix: uint, pow: uint) -> T {
     let _0: T = Zero::zero();
     let _1: T = One::one();
@@ -384,18 +385,19 @@ pub fn pow_with_uint<T:NumCast+One+Zero+Copy+Quot<T,T>+Mul<T,T>>(
     total
 }
 
+/// Helper function for testing numeric operations
 #[cfg(test)]
 pub fn test_num<T:Num + NumCast>(ten: T, two: T) {
     assert_eq!(ten.add(&two),  cast(12));
     assert_eq!(ten.sub(&two),  cast(8));
     assert_eq!(ten.mul(&two),  cast(20));
-    assert_eq!(ten.quot(&two), cast(5));
+    assert_eq!(ten.div(&two), cast(5));
     assert_eq!(ten.rem(&two),  cast(0));
 
     assert_eq!(ten.add(&two),  ten + two);
     assert_eq!(ten.sub(&two),  ten - two);
     assert_eq!(ten.mul(&two),  ten * two);
-    assert_eq!(ten.quot(&two), ten / two);
+    assert_eq!(ten.div(&two), ten / two);
     assert_eq!(ten.rem(&two),  ten % two);
 }
 
diff --git a/src/libcore/num/strconv.rs b/src/libcore/num/strconv.rs
index 004789e7fc1..c16a29f8295 100644
--- a/src/libcore/num/strconv.rs
+++ b/src/libcore/num/strconv.rs
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 use core::cmp::{Ord, Eq};
-use ops::{Add, Sub, Mul, Quot, Rem, Neg};
+use ops::{Add, Sub, Mul, Div, Rem, Neg};
 use option::{None, Option, Some};
 use char;
 use str;
@@ -58,7 +58,7 @@ fn is_neg_inf<T:Eq+NumStrConv>(num: &T) -> bool {
 }
 
 #[inline(always)]
-fn is_neg_zero<T:Eq+One+Zero+NumStrConv+Quot<T,T>>(num: &T) -> bool {
+fn is_neg_zero<T:Eq+One+Zero+NumStrConv+Div<T,T>>(num: &T) -> bool {
     let _0: T = Zero::zero();
     let _1: T = One::one();
 
@@ -171,7 +171,7 @@ static nan_buf:          [u8, ..3] = ['N' as u8, 'a' as u8, 'N' as u8];
  * - Fails if `radix` < 2 or `radix` > 36.
  */
 pub fn to_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+NumStrConv+Copy+
-                                  Quot<T,T>+Neg<T>+Rem<T,T>+Mul<T,T>>(
+                                  Div<T,T>+Neg<T>+Rem<T,T>+Mul<T,T>>(
         num: &T, radix: uint, negative_zero: bool,
         sign: SignFormat, digits: SignificantDigits) -> (~[u8], bool) {
     if (radix as int) < 2 {
@@ -379,7 +379,7 @@ pub fn to_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+NumStrConv+Copy+
  */
 #[inline(always)]
 pub fn to_str_common<T:NumCast+Zero+One+Eq+Ord+NumStrConv+Copy+
-                            Quot<T,T>+Neg<T>+Rem<T,T>+Mul<T,T>>(
+                            Div<T,T>+Neg<T>+Rem<T,T>+Mul<T,T>>(
         num: &T, radix: uint, negative_zero: bool,
         sign: SignFormat, digits: SignificantDigits) -> (~str, bool) {
     let (bytes, special) = to_str_bytes_common(num, radix,
@@ -432,7 +432,7 @@ priv static DIGIT_E_RADIX: uint = ('e' as uint) - ('a' as uint) + 11u;
  * - Fails if `radix` > 18 and `special == true` due to conflict
  *   between digit and lowest first character in `inf` and `NaN`, the `'i'`.
  */
-pub fn from_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Copy+Quot<T,T>+
+pub fn from_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Copy+Div<T,T>+
                                     Mul<T,T>+Sub<T,T>+Neg<T>+Add<T,T>+
                                     NumStrConv>(
         buf: &[u8], radix: uint, negative: bool, fractional: bool,
@@ -629,7 +629,7 @@ pub fn from_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Copy+Quot<T,T>+
  * `from_str_bytes_common()`, for details see there.
  */
 #[inline(always)]
-pub fn from_str_common<T:NumCast+Zero+One+Eq+Ord+Copy+Quot<T,T>+Mul<T,T>+
+pub fn from_str_common<T:NumCast+Zero+One+Eq+Ord+Copy+Div<T,T>+Mul<T,T>+
                               Sub<T,T>+Neg<T>+Add<T,T>+NumStrConv>(
         buf: &str, radix: uint, negative: bool, fractional: bool,
         special: bool, exponent: ExponentFormat, empty_zero: bool,
diff --git a/src/libcore/num/uint-template.rs b/src/libcore/num/uint-template.rs
index 2d204449468..6d0f1fe1fc7 100644
--- a/src/libcore/num/uint-template.rs
+++ b/src/libcore/num/uint-template.rs
@@ -11,7 +11,6 @@
 use T = self::inst::T;
 use T_SIGNED = self::inst::T_SIGNED;
 
-use from_str::FromStr;
 use num::{ToStrRadix, FromStrRadix};
 use num::{Zero, One, strconv};
 use prelude::*;
@@ -31,7 +30,7 @@ pub fn sub(x: T, y: T) -> T { x - y }
 #[inline(always)]
 pub fn mul(x: T, y: T) -> T { x * y }
 #[inline(always)]
-pub fn quot(x: T, y: T) -> T { x / y }
+pub fn div(x: T, y: T) -> T { x / y }
 #[inline(always)]
 pub fn rem(x: T, y: T) -> T { x % y }
 
@@ -167,9 +166,9 @@ impl Mul<T,T> for T {
 }
 
 #[cfg(notest)]
-impl Quot<T,T> for T {
+impl Div<T,T> for T {
     #[inline(always)]
-    fn quot(&self, other: &T) -> T { *self / *other }
+    fn div(&self, other: &T) -> T { *self / *other }
 }
 
 #[cfg(notest)]
@@ -187,23 +186,23 @@ impl Neg<T> for T {
 impl Unsigned for T {}
 
 impl Integer for T {
-    /// Unsigned integer division. Returns the same result as `quot` (`/`).
+    /// Calculates `div` (`\`) and `rem` (`%`) simultaneously
     #[inline(always)]
-    fn div(&self, other: &T) -> T { *self / *other }
+    fn div_rem(&self, other: &T) -> (T,T) {
+        (*self / *other, *self % *other)
+    }
 
-    /// Unsigned integer modulo operation. Returns the same result as `rem` (`%`).
+    /// Unsigned integer division. Returns the same result as `div` (`/`).
     #[inline(always)]
-    fn modulo(&self, other: &T) -> T { *self / *other }
+    fn div_floor(&self, other: &T) -> T { *self / *other }
 
-    /// Calculates `div` and `modulo` simultaneously
+    /// Unsigned integer modulo operation. Returns the same result as `rem` (`%`).
     #[inline(always)]
-    fn div_mod(&self, other: &T) -> (T,T) {
-        (*self / *other, *self % *other)
-    }
+    fn mod_floor(&self, other: &T) -> T { *self / *other }
 
-    /// Calculates `quot` (`\`) and `rem` (`%`) simultaneously
+    /// Calculates `div_floor` and `modulo_floor` simultaneously
     #[inline(always)]
-    fn quot_rem(&self, other: &T) -> (T,T) {
+    fn div_mod_floor(&self, other: &T) -> (T,T) {
         (*self / *other, *self % *other)
     }
 
diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs
index 18dcf34e49b..47ff45be687 100644
--- a/src/libcore/ops.rs
+++ b/src/libcore/ops.rs
@@ -30,9 +30,9 @@ pub trait Mul<RHS,Result> {
     fn mul(&self, rhs: &RHS) -> Result;
 }
 
-#[lang="quot"]
-pub trait Quot<RHS,Result> {
-    fn quot(&self, rhs: &RHS) -> Result;
+#[lang="div"]
+pub trait Div<RHS,Result> {
+    fn div(&self, rhs: &RHS) -> Result;
 }
 
 #[lang="rem"]
diff --git a/src/libcore/option.rs b/src/libcore/option.rs
index 5abf376ddde..b7c51147fba 100644
--- a/src/libcore/option.rs
+++ b/src/libcore/option.rs
@@ -461,11 +461,3 @@ fn test_get_or_zero() {
     let no_stuff: Option<int> = None;
     assert!(no_stuff.get_or_zero() == 0);
 }
-
-// Local Variables:
-// mode: rust;
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
diff --git a/src/libcore/os.rs b/src/libcore/os.rs
index d5271ec228b..42c77a687e5 100644
--- a/src/libcore/os.rs
+++ b/src/libcore/os.rs
@@ -38,6 +38,7 @@ use ptr;
 use str;
 use task;
 use uint;
+use unstable::finally::Finally;
 use vec;
 
 pub use libc::fclose;
@@ -372,8 +373,9 @@ pub fn pipe() -> Pipe {
         // inheritance has to be handled in a different way that I do not
         // fully understand. Here we explicitly make the pipe non-inheritable,
         // which means to pass it to a subprocess they need to be duplicated
-        // first, as in rust_run_program.
-        let mut fds = Pipe {in: 0 as c_int, out: 0 as c_int};
+        // first, as in core::run.
+        let mut fds = Pipe {in: 0 as c_int,
+                    out: 0 as c_int };
         let res = libc::pipe(&mut fds.in, 1024 as ::libc::c_uint,
                              (libc::O_BINARY | libc::O_NOINHERIT) as c_int);
         assert!((res == 0 as c_int));
@@ -770,6 +772,28 @@ pub fn list_dir_path(p: &Path) -> ~[~Path] {
     list_dir(p).map(|f| ~p.push(*f))
 }
 
+/// Removes a directory at the specified path, after removing
+/// all its contents. Use carefully!
+pub fn remove_dir_recursive(p: &Path) -> bool {
+    let mut error_happened = false;
+    for walk_dir(p) |inner| {
+        if !error_happened {
+            if path_is_dir(inner) {
+                if !remove_dir_recursive(inner) {
+                    error_happened = true;
+                }
+            }
+            else {
+                if !remove_file(inner) {
+                    error_happened = true;
+                }
+            }
+        }
+    };
+    // Directory should now be empty
+    !error_happened && remove_dir(p)
+}
+
 /// Removes a directory at the specified path
 pub fn remove_dir(p: &Path) -> bool {
    return rmdir(p);
@@ -817,6 +841,36 @@ pub fn change_dir(p: &Path) -> bool {
     }
 }
 
+/// Changes the current working directory to the specified
+/// path while acquiring a global lock, then calls `action`.
+/// If the change is successful, releases the lock and restores the
+/// CWD to what it was before, returning true.
+/// Returns false if the directory doesn't exist or if the directory change
+/// is otherwise unsuccessful.
+pub fn change_dir_locked(p: &Path, action: &fn()) -> bool {
+    use unstable::global::global_data_clone_create;
+    use unstable::{Exclusive, exclusive};
+
+    fn key(_: Exclusive<()>) { }
+
+    let result = unsafe {
+        global_data_clone_create(key, || {
+            ~exclusive(())
+        })
+    };
+
+    do result.with_imm() |_| {
+        let old_dir = os::getcwd();
+        if change_dir(p) {
+            action();
+            change_dir(&old_dir)
+        }
+        else {
+            false
+        }
+    }
+}
+
 /// Copies a file from one location to another
 pub fn copy_file(from: &Path, to: &Path) -> bool {
     return do_copy_file(from, to);
@@ -845,6 +899,10 @@ pub fn copy_file(from: &Path, to: &Path) -> bool {
             if istream as uint == 0u {
                 return false;
             }
+            // Preserve permissions
+            let from_mode = from.get_mode().expect("copy_file: couldn't get permissions \
+                                                    for source file");
+
             let ostream = do as_c_charp(to.to_str()) |top| {
                 do as_c_charp("w+b") |modebuf| {
                     libc::fopen(top, modebuf)
@@ -876,6 +934,15 @@ pub fn copy_file(from: &Path, to: &Path) -> bool {
             }
             fclose(istream);
             fclose(ostream);
+
+            // Give the new file the old file's permissions
+            unsafe {
+                if do str::as_c_str(to.to_str()) |to_buf| {
+                    libc::chmod(to_buf, from_mode as mode_t)
+                } != 0 {
+                    return false; // should be a condition...
+                }
+            }
             return ok;
         }
     }
@@ -1152,6 +1219,88 @@ pub fn set_args(new_args: ~[~str]) {
     }
 }
 
+// FIXME #6100 we should really use an internal implementation of this - using
+// the POSIX glob functions isn't portable to windows, probably has slight
+// inconsistencies even where it is implemented, and makes extending
+// functionality a lot more difficult
+// FIXME #6101 also provide a non-allocating version - each_glob or so?
+/// Returns a vector of Path objects that match the given glob pattern
+#[cfg(target_os = "linux")]
+#[cfg(target_os = "android")]
+#[cfg(target_os = "freebsd")]
+#[cfg(target_os = "macos")]
+pub fn glob(pattern: &str) -> ~[Path] {
+    #[cfg(target_os = "linux")]
+    #[cfg(target_os = "android")]
+    fn default_glob_t () -> libc::glob_t {
+        libc::glob_t {
+            gl_pathc: 0,
+            gl_pathv: ptr::null(),
+            gl_offs: 0,
+            __unused1: ptr::null(),
+            __unused2: ptr::null(),
+            __unused3: ptr::null(),
+            __unused4: ptr::null(),
+            __unused5: ptr::null(),
+        }
+    }
+
+    #[cfg(target_os = "freebsd")]
+    fn default_glob_t () -> libc::glob_t {
+        libc::glob_t {
+            gl_pathc: 0,
+            __unused1: 0,
+            gl_offs: 0,
+            __unused2: 0,
+            gl_pathv: ptr::null(),
+            __unused3: ptr::null(),
+            __unused4: ptr::null(),
+            __unused5: ptr::null(),
+            __unused6: ptr::null(),
+            __unused7: ptr::null(),
+            __unused8: ptr::null(),
+        }
+    }
+
+    #[cfg(target_os = "macos")]
+    fn default_glob_t () -> libc::glob_t {
+        libc::glob_t {
+            gl_pathc: 0,
+            __unused1: 0,
+            gl_offs: 0,
+            __unused2: 0,
+            gl_pathv: ptr::null(),
+            __unused3: ptr::null(),
+            __unused4: ptr::null(),
+            __unused5: ptr::null(),
+            __unused6: ptr::null(),
+            __unused7: ptr::null(),
+            __unused8: ptr::null(),
+        }
+    }
+
+    let mut g = default_glob_t();
+    do str::as_c_str(pattern) |c_pattern| {
+        unsafe { libc::glob(c_pattern, 0, ptr::null(), &mut g) }
+    };
+    do(|| {
+        let paths = unsafe {
+            vec::raw::from_buf_raw(g.gl_pathv, g.gl_pathc as uint)
+        };
+        do paths.map |&c_str| {
+            Path(unsafe { str::raw::from_c_str(c_str) })
+        }
+    }).finally {
+        unsafe { libc::globfree(&mut g) };
+    }
+}
+
+/// Returns a vector of Path objects that match the given glob pattern
+#[cfg(target_os = "win32")]
+pub fn glob(pattern: &str) -> ~[Path] {
+    fail!(~"glob() is unimplemented on Windows")
+}
+
 #[cfg(target_os = "macos")]
 extern {
     // These functions are in crt_externs.h.
@@ -1480,6 +1629,7 @@ mod tests {
                       == buf.len() as size_t))
           }
           assert!((libc::fclose(ostream) == (0u as c_int)));
+          let in_mode = in.get_mode();
           let rs = os::copy_file(&in, &out);
           if (!os::path_exists(&in)) {
             fail!(fmt!("%s doesn't exist", in.to_str()));
@@ -1487,6 +1637,7 @@ mod tests {
           assert!((rs));
           let rslt = run::run_program(~"diff", ~[in.to_str(), out.to_str()]);
           assert!((rslt == 0));
+          assert!(out.get_mode() == in_mode);
           assert!((remove_file(&in)));
           assert!((remove_file(&out)));
         }
diff --git a/src/libcore/owned.rs b/src/libcore/owned.rs
index c483ec79e21..599591e2f6d 100644
--- a/src/libcore/owned.rs
+++ b/src/libcore/owned.rs
@@ -31,4 +31,3 @@ impl<T:Ord> Ord for ~T {
     #[inline(always)]
     fn gt(&self, other: &~T) -> bool { *(*self) > *(*other) }
 }
-
diff --git a/src/libcore/pipes.rs b/src/libcore/pipes.rs
index 95b24d20a4b..19674900f90 100644
--- a/src/libcore/pipes.rs
+++ b/src/libcore/pipes.rs
@@ -86,7 +86,9 @@ use cast::{forget, transmute, transmute_copy};
 use either::{Either, Left, Right};
 use kinds::Owned;
 use libc;
+use ops::Drop;
 use option::{None, Option, Some};
+use unstable::finally::Finally;
 use unstable::intrinsics;
 use ptr;
 use task;
@@ -301,7 +303,7 @@ struct BufferResource<T> {
 }
 
 #[unsafe_destructor]
-impl<T> ::ops::Drop for BufferResource<T> {
+impl<T> Drop for BufferResource<T> {
     fn finalize(&self) {
         unsafe {
             let b = move_it!(self.buffer);
@@ -395,26 +397,22 @@ pub fn try_recv<T:Owned,Tbuffer:Owned>(p: RecvPacketBuffered<T, Tbuffer>)
     let p_ = p.unwrap();
     let p = unsafe { &*p_ };
 
-    #[unsafe_destructor]
-    struct DropState<'self> {
-        p: &'self PacketHeader,
-
-        drop {
-            unsafe {
-                if task::failing() {
-                    self.p.state = Terminated;
-                    let old_task = swap_task(&mut self.p.blocked_task,
-                                             ptr::null());
-                    if !old_task.is_null() {
-                        rustrt::rust_task_deref(old_task);
-                    }
+    do (|| {
+        try_recv_(p)
+    }).finally {
+        unsafe {
+            if task::failing() {
+                p.header.state = Terminated;
+                let old_task = swap_task(&mut p.header.blocked_task, ptr::null());
+                if !old_task.is_null() {
+                    rustrt::rust_task_deref(old_task);
                 }
             }
         }
-    };
-
-    let _drop_state = DropState { p: &p.header };
+    }
+}
 
+fn try_recv_<T:Owned>(p: &Packet<T>) -> Option<T> {
     // optimistic path
     match p.header.state {
       Full => {
@@ -451,7 +449,7 @@ pub fn try_recv<T:Owned,Tbuffer:Owned>(p: RecvPacketBuffered<T, Tbuffer>)
                                        Blocked);
         match old_state {
           Empty => {
-            debug!("no data available on %?, going to sleep.", p_);
+            debug!("no data available on %?, going to sleep.", p);
             if count == 0 {
                 wait_event(this);
             }
@@ -641,7 +639,7 @@ pub struct SendPacketBuffered<T, Tbuffer> {
 }
 
 #[unsafe_destructor]
-impl<T:Owned,Tbuffer:Owned> ::ops::Drop for SendPacketBuffered<T,Tbuffer> {
+impl<T:Owned,Tbuffer:Owned> Drop for SendPacketBuffered<T,Tbuffer> {
     fn finalize(&self) {
         //if self.p != none {
         //    debug!("drop send %?", option::get(self.p));
@@ -710,7 +708,7 @@ pub struct RecvPacketBuffered<T, Tbuffer> {
 }
 
 #[unsafe_destructor]
-impl<T:Owned,Tbuffer:Owned> ::ops::Drop for RecvPacketBuffered<T,Tbuffer> {
+impl<T:Owned,Tbuffer:Owned> Drop for RecvPacketBuffered<T,Tbuffer> {
     fn finalize(&self) {
         //if self.p != none {
         //    debug!("drop recv %?", option::get(self.p));
diff --git a/src/libcore/prelude.rs b/src/libcore/prelude.rs
index 318725d2822..42401ae5a1f 100644
--- a/src/libcore/prelude.rs
+++ b/src/libcore/prelude.rs
@@ -14,7 +14,7 @@
 
 pub use either::{Either, Left, Right};
 pub use kinds::{Const, Copy, Owned, Durable};
-pub use ops::{Add, Sub, Mul, Quot, Rem, Neg, Not};
+pub use ops::{Add, Sub, Mul, Div, Rem, Neg, Not};
 pub use ops::{BitAnd, BitOr, BitXor};
 pub use ops::{Drop};
 pub use ops::{Shl, Shr, Index};
@@ -28,7 +28,7 @@ pub use io::{print, println};
 /* Reexported types and traits */
 
 pub use clone::Clone;
-pub use cmp::{Eq, Ord, TotalEq, TotalOrd, Ordering, Less, Equal, Greater};
+pub use cmp::{Eq, Ord, TotalEq, TotalOrd, Ordering, Less, Equal, Greater, Equiv};
 pub use container::{Container, Mutable, Map, Set};
 pub use hash::Hash;
 pub use old_iter::{BaseIter, ReverseIter, MutableIter, ExtendedIter, EqIter};
@@ -48,6 +48,7 @@ pub use path::WindowsPath;
 pub use ptr::Ptr;
 pub use ascii::{Ascii, AsciiCast, OwnedAsciiCast, AsciiStr};
 pub use str::{StrSlice, OwnedStr};
+pub use from_str::{FromStr};
 pub use to_bytes::IterBytes;
 pub use to_str::{ToStr, ToStrConsume};
 pub use tuple::{CopyableTuple, ImmutableTuple, ExtendedTupleOps};
diff --git a/src/libcore/rand.rs b/src/libcore/rand.rs
index 9fa099cabbf..80f69f067eb 100644
--- a/src/libcore/rand.rs
+++ b/src/libcore/rand.rs
@@ -16,6 +16,9 @@ and so can be used to generate any type that implements `Rand`. Type inference
 means that often a simple call to `rand::random()` or `rng.gen()` will
 suffice, but sometimes an annotation is required, e.g. `rand::random::<float>()`.
 
+See the `distributions` submodule for sampling random numbers from
+distributions like normal and exponential.
+
 # Examples
 ~~~
 use core::rand::RngUtil;
@@ -47,6 +50,9 @@ use util;
 use vec;
 use libc::size_t;
 
+#[path="rand/distributions.rs"]
+pub mod distributions;
+
 /// A type that can be randomly generated using an Rng
 pub trait Rand {
     fn rand<R: Rng>(rng: &R) -> Self;
@@ -1067,12 +1073,3 @@ mod tests {
         }
     }
 }
-
-
-// Local Variables:
-// mode: rust;
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
diff --git a/src/libcore/rand/distributions.rs b/src/libcore/rand/distributions.rs
new file mode 100644
index 00000000000..a644f60db69
--- /dev/null
+++ b/src/libcore/rand/distributions.rs
@@ -0,0 +1,148 @@
+// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+//! Sampling from random distributions
+
+// Some implementations use the Ziggurat method
+// https://en.wikipedia.org/wiki/Ziggurat_algorithm
+//
+// The version used here is ZIGNOR [Doornik 2005, "An Improved
+// Ziggurat Method to Generate Normal Random Samples"] which is slower
+// (about double, it generates an extra random number) than the
+// canonical version [Marsaglia & Tsang 2000, "The Ziggurat Method for
+// Generating Random Variables"], but more robust. If one wanted, one
+// could implement VIZIGNOR the ZIGNOR paper for more speed.
+
+use prelude::*;
+use rand::{Rng,Rand};
+
+mod ziggurat_tables;
+
+// inlining should mean there is no performance penalty for this
+#[inline(always)]
+fn ziggurat<R:Rng>(rng: &R,
+                   center_u: bool,
+                   X: ziggurat_tables::ZigTable,
+                   F: ziggurat_tables::ZigTable,
+                   F_DIFF: ziggurat_tables::ZigTable,
+                   pdf: &'static fn(f64) -> f64, // probability density function
+                   zero_case: &'static fn(&R, f64) -> f64) -> f64 {
+    loop {
+        let u = if center_u {2.0 * rng.gen() - 1.0} else {rng.gen()};
+        let i: uint = rng.gen::<uint>() & 0xff;
+        let x = u * X[i];
+
+        let test_x = if center_u {f64::abs(x)} else {x};
+
+        // algebraically equivalent to |u| < X[i+1]/X[i] (or u < X[i+1]/X[i])
+        if test_x < X[i + 1] {
+            return x;
+        }
+        if i == 0 {
+            return zero_case(rng, u);
+        }
+        // algebraically equivalent to f1 + DRanU()*(f0 - f1) < 1
+        if F[i+1] + F_DIFF[i+1] * rng.gen() < pdf(x) {
+            return x;
+        }
+    }
+}
+
+/// A wrapper around an `f64` to generate N(0, 1) random numbers (a.k.a.  a
+/// standard normal, or Gaussian). Multiplying the generated values by the
+/// desired standard deviation `sigma` then adding the desired mean `mu` will
+/// give N(mu, sigma^2) distributed random numbers.
+///
+/// Note that this has to be unwrapped before use as an `f64` (using either
+/// `*` or `cast::transmute` is safe).
+///
+/// # Example
+///
+/// ~~~
+/// use core::rand::distributions::StandardNormal;
+///
+/// fn main() {
+///     let normal = 2.0 + (*rand::random::<StandardNormal>()) * 3.0;
+///     println(fmt!("%f is from a N(2, 9) distribution", normal))
+/// }
+/// ~~~
+pub struct StandardNormal(f64);
+
+impl Rand for StandardNormal {
+    fn rand<R:Rng>(rng: &R) -> StandardNormal {
+        #[inline(always)]
+        fn pdf(x: f64) -> f64 {
+            f64::exp((-x*x/2.0) as f64) as f64
+        }
+        #[inline(always)]
+        fn zero_case<R:Rng>(rng: &R, u: f64) -> f64 {
+            // compute a random number in the tail by hand
+
+            // strange initial conditions, because the loop is not
+            // do-while, so the condition should be true on the first
+            // run, they get overwritten anyway (0 < 1, so these are
+            // good).
+            let mut x = 1.0, y = 0.0;
+
+            // XXX infinities?
+            while -2.0*y < x * x {
+                x = f64::ln(rng.gen()) / ziggurat_tables::ZIG_NORM_R;
+                y = f64::ln(rng.gen());
+            }
+            if u < 0.0 {x-ziggurat_tables::ZIG_NORM_R} else {ziggurat_tables::ZIG_NORM_R-x}
+        }
+
+        StandardNormal(ziggurat(
+            rng,
+            true, // this is symmetric
+            &ziggurat_tables::ZIG_NORM_X,
+            &ziggurat_tables::ZIG_NORM_F, &ziggurat_tables::ZIG_NORM_F_DIFF,
+            pdf, zero_case))
+    }
+}
+
+/// A wrapper around an `f64` to generate Exp(1) random numbers. Dividing by
+/// the desired rate `lambda` will give Exp(lambda) distributed random
+/// numbers.
+///
+/// Note that this has to be unwrapped before use as an `f64` (using either
+/// `*` or `cast::transmute` is safe).
+///
+/// # Example
+///
+/// ~~~
+/// use core::rand::distributions::Exp1;
+///
+/// fn main() {
+///     let exp2 = (*rand::random::<Exp1>()) * 0.5;
+///     println(fmt!("%f is from a Exp(2) distribution", exp2));
+/// }
+/// ~~~
+pub struct Exp1(f64);
+
+// This could be done via `-f64::ln(rng.gen::<f64>())` but that is slower.
+impl Rand for Exp1 {
+    #[inline]
+    fn rand<R:Rng>(rng: &R) -> Exp1 {
+        #[inline(always)]
+        fn pdf(x: f64) -> f64 {
+            f64::exp(-x)
+        }
+        #[inline(always)]
+        fn zero_case<R:Rng>(rng: &R, _u: f64) -> f64 {
+            ziggurat_tables::ZIG_EXP_R - f64::ln(rng.gen())
+        }
+
+        Exp1(ziggurat(rng, false,
+                      &ziggurat_tables::ZIG_EXP_X,
+                      &ziggurat_tables::ZIG_EXP_F, &ziggurat_tables::ZIG_EXP_F_DIFF,
+                      pdf, zero_case))
+    }
+}
diff --git a/src/libcore/rand/ziggurat_tables.rs b/src/libcore/rand/ziggurat_tables.rs
new file mode 100644
index 00000000000..aca2457cac4
--- /dev/null
+++ b/src/libcore/rand/ziggurat_tables.rs
@@ -0,0 +1,412 @@
+// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Tables for distributions which are sampled using the ziggurat
+// algorithm. Autogenerated by `ziggurat_tables.py`.
+
+pub type ZigTable = &'static [f64, .. 257];
+pub static ZIG_NORM_R: f64 = 3.654152885361008796;
+pub static ZIG_NORM_X: [f64, .. 257] =
+    [3.910757959537090045, 3.654152885361008796, 3.449278298560964462, 3.320244733839166074,
+     3.224575052047029100, 3.147889289517149969, 3.083526132001233044, 3.027837791768635434,
+     2.978603279880844834, 2.934366867207854224, 2.894121053612348060, 2.857138730872132548,
+     2.822877396825325125, 2.790921174000785765, 2.760944005278822555, 2.732685359042827056,
+     2.705933656121858100, 2.680514643284522158, 2.656283037575502437, 2.633116393630324570,
+     2.610910518487548515, 2.589575986706995181, 2.569035452680536569, 2.549221550323460761,
+     2.530075232158516929, 2.511544441625342294, 2.493583041269680667, 2.476149939669143318,
+     2.459208374333311298, 2.442725318198956774, 2.426670984935725972, 2.411018413899685520,
+     2.395743119780480601, 2.380822795170626005, 2.366237056715818632, 2.351967227377659952,
+     2.337996148795031370, 2.324308018869623016, 2.310888250599850036, 2.297723348901329565,
+     2.284800802722946056, 2.272108990226823888, 2.259637095172217780, 2.247375032945807760,
+     2.235313384928327984, 2.223443340090905718, 2.211756642882544366, 2.200245546609647995,
+     2.188902771624720689, 2.177721467738641614, 2.166695180352645966, 2.155817819875063268,
+     2.145083634046203613, 2.134487182844320152, 2.124023315687815661, 2.113687150684933957,
+     2.103474055713146829, 2.093379631137050279, 2.083399693996551783, 2.073530263516978778,
+     2.063767547809956415, 2.054107931648864849, 2.044547965215732788, 2.035084353727808715,
+     2.025713947862032960, 2.016433734904371722, 2.007240830558684852, 1.998132471356564244,
+     1.989106007615571325, 1.980158896898598364, 1.971288697931769640, 1.962493064942461896,
+     1.953769742382734043, 1.945116560006753925, 1.936531428273758904, 1.928012334050718257,
+     1.919557336591228847, 1.911164563769282232, 1.902832208548446369, 1.894558525668710081,
+     1.886341828534776388, 1.878180486290977669, 1.870072921069236838, 1.862017605397632281,
+     1.854013059758148119, 1.846057850283119750, 1.838150586580728607, 1.830289919680666566,
+     1.822474540091783224, 1.814703175964167636, 1.806974591348693426, 1.799287584547580199,
+     1.791640986550010028, 1.784033659547276329, 1.776464495522344977, 1.768932414909077933,
+     1.761436365316706665, 1.753975320315455111, 1.746548278279492994, 1.739154261283669012,
+     1.731792314050707216, 1.724461502945775715, 1.717160915015540690, 1.709889657069006086,
+     1.702646854797613907, 1.695431651932238548, 1.688243209434858727, 1.681080704722823338,
+     1.673943330923760353, 1.666830296159286684, 1.659740822855789499, 1.652674147080648526,
+     1.645629517902360339, 1.638606196773111146, 1.631603456932422036, 1.624620582830568427,
+     1.617656869570534228, 1.610711622367333673, 1.603784156023583041, 1.596873794420261339,
+     1.589979870021648534, 1.583101723393471438, 1.576238702733332886, 1.569390163412534456,
+     1.562555467528439657, 1.555733983466554893, 1.548925085471535512, 1.542128153226347553,
+     1.535342571438843118, 1.528567729435024614, 1.521803020758293101, 1.515047842773992404,
+     1.508301596278571965, 1.501563685112706548, 1.494833515777718391, 1.488110497054654369,
+     1.481394039625375747, 1.474683555695025516, 1.467978458615230908, 1.461278162507407830,
+     1.454582081885523293, 1.447889631277669675, 1.441200224845798017, 1.434513276002946425,
+     1.427828197027290358, 1.421144398672323117, 1.414461289772464658, 1.407778276843371534,
+     1.401094763676202559, 1.394410150925071257, 1.387723835686884621, 1.381035211072741964,
+     1.374343665770030531, 1.367648583594317957, 1.360949343030101844, 1.354245316759430606,
+     1.347535871177359290, 1.340820365893152122, 1.334098153216083604, 1.327368577624624679,
+     1.320630975217730096, 1.313884673146868964, 1.307128989027353860, 1.300363230327433728,
+     1.293586693733517645, 1.286798664489786415, 1.279998415710333237, 1.273185207661843732,
+     1.266358287014688333, 1.259516886060144225, 1.252660221891297887, 1.245787495544997903,
+     1.238897891102027415, 1.231990574742445110, 1.225064693752808020, 1.218119375481726552,
+     1.211153726239911244, 1.204166830140560140, 1.197157747875585931, 1.190125515422801650,
+     1.183069142678760732, 1.175987612011489825, 1.168879876726833800, 1.161744859441574240,
+     1.154581450355851802, 1.147388505416733873, 1.140164844363995789, 1.132909248648336975,
+     1.125620459211294389, 1.118297174115062909, 1.110938046009249502, 1.103541679420268151,
+     1.096106627847603487, 1.088631390649514197, 1.081114409698889389, 1.073554065787871714,
+     1.065948674757506653, 1.058296483326006454, 1.050595664586207123, 1.042844313139370538,
+     1.035040439828605274, 1.027181966030751292, 1.019266717460529215, 1.011292417434978441,
+     1.003256679539591412, 0.995156999629943084, 0.986990747093846266, 0.978755155288937750,
+     0.970447311058864615, 0.962064143217605250, 0.953602409875572654, 0.945058684462571130,
+     0.936429340280896860, 0.927710533396234771, 0.918898183643734989, 0.909987953490768997,
+     0.900975224455174528, 0.891855070726792376, 0.882622229578910122, 0.873271068082494550,
+     0.863795545546826915, 0.854189171001560554, 0.844444954902423661, 0.834555354079518752,
+     0.824512208745288633, 0.814306670128064347, 0.803929116982664893, 0.793369058833152785,
+     0.782615023299588763, 0.771654424216739354, 0.760473406422083165, 0.749056662009581653,
+     0.737387211425838629, 0.725446140901303549, 0.713212285182022732, 0.700661841097584448,
+     0.687767892786257717, 0.674499822827436479, 0.660822574234205984, 0.646695714884388928,
+     0.632072236375024632, 0.616896989996235545, 0.601104617743940417, 0.584616766093722262,
+     0.567338257040473026, 0.549151702313026790, 0.529909720646495108, 0.509423329585933393,
+     0.487443966121754335, 0.463634336771763245, 0.437518402186662658, 0.408389134588000746,
+     0.375121332850465727, 0.335737519180459465, 0.286174591747260509, 0.215241895913273806,
+     0.000000000000000000];
+pub static ZIG_NORM_F: [f64, .. 257] =
+    [0.000477467764586655, 0.001260285930498598, 0.002609072746106363, 0.004037972593371872,
+     0.005522403299264754, 0.007050875471392110, 0.008616582769422917, 0.010214971439731100,
+     0.011842757857943104, 0.013497450601780807, 0.015177088307982072, 0.016880083152595839,
+     0.018605121275783350, 0.020351096230109354, 0.022117062707379922, 0.023902203305873237,
+     0.025705804008632656, 0.027527235669693315, 0.029365939758230111, 0.031221417192023690,
+     0.033093219458688698, 0.034980941461833073, 0.036884215688691151, 0.038802707404656918,
+     0.040736110656078753, 0.042684144916619378, 0.044646552251446536, 0.046623094902089664,
+     0.048613553216035145, 0.050617723861121788, 0.052635418276973649, 0.054666461325077916,
+     0.056710690106399467, 0.058767952921137984, 0.060838108349751806, 0.062921024437977854,
+     0.065016577971470438, 0.067124653828023989, 0.069245144397250269, 0.071377949059141965,
+     0.073522973714240991, 0.075680130359194964, 0.077849336702372207, 0.080030515814947509,
+     0.082223595813495684, 0.084428509570654661, 0.086645194450867782, 0.088873592068594229,
+     0.091113648066700734, 0.093365311913026619, 0.095628536713353335, 0.097903279039215627,
+     0.100189498769172020, 0.102487158942306270, 0.104796225622867056, 0.107116667775072880,
+     0.109448457147210021, 0.111791568164245583, 0.114145977828255210, 0.116511665626037014,
+     0.118888613443345698, 0.121276805485235437, 0.123676228202051403, 0.126086870220650349,
+     0.128508722280473636, 0.130941777174128166, 0.133386029692162844, 0.135841476571757352,
+     0.138308116449064322, 0.140785949814968309, 0.143274978974047118, 0.145775208006537926,
+     0.148286642733128721, 0.150809290682410169, 0.153343161060837674, 0.155888264725064563,
+     0.158444614156520225, 0.161012223438117663, 0.163591108232982951, 0.166181285765110071,
+     0.168782774801850333, 0.171395595638155623, 0.174019770082499359, 0.176655321444406654,
+     0.179302274523530397, 0.181960655600216487, 0.184630492427504539, 0.187311814224516926,
+     0.190004651671193070, 0.192709036904328807, 0.195425003514885592, 0.198152586546538112,
+     0.200891822495431333, 0.203642749311121501, 0.206405406398679298, 0.209179834621935651,
+     0.211966076307852941, 0.214764175252008499, 0.217574176725178370, 0.220396127481011589,
+     0.223230075764789593, 0.226076071323264877, 0.228934165415577484, 0.231804410825248525,
+     0.234686861873252689, 0.237581574432173676, 0.240488605941449107, 0.243408015423711988,
+     0.246339863502238771, 0.249284212419516704, 0.252241126056943765, 0.255210669955677150,
+     0.258192911338648023, 0.261187919133763713, 0.264195763998317568, 0.267216518344631837,
+     0.270250256366959984, 0.273297054069675804, 0.276356989296781264, 0.279430141762765316,
+     0.282516593084849388, 0.285616426816658109, 0.288729728483353931, 0.291856585618280984,
+     0.294997087801162572, 0.298151326697901342, 0.301319396102034120, 0.304501391977896274,
+     0.307697412505553769, 0.310907558127563710, 0.314131931597630143, 0.317370638031222396,
+     0.320623784958230129, 0.323891482377732021, 0.327173842814958593, 0.330470981380537099,
+     0.333783015832108509, 0.337110066638412809, 0.340452257045945450, 0.343809713148291340,
+     0.347182563958251478, 0.350570941482881204, 0.353974980801569250, 0.357394820147290515,
+     0.360830600991175754, 0.364282468130549597, 0.367750569780596226, 0.371235057669821344,
+     0.374736087139491414, 0.378253817247238111, 0.381788410875031348, 0.385340034841733958,
+     0.388908860020464597, 0.392495061461010764, 0.396098818517547080, 0.399720314981931668,
+     0.403359739222868885, 0.407017284331247953, 0.410693148271983222, 0.414387534042706784,
+     0.418100649839684591, 0.421832709231353298, 0.425583931339900579, 0.429354541031341519,
+     0.433144769114574058, 0.436954852549929273, 0.440785034667769915, 0.444635565397727750,
+     0.448506701509214067, 0.452398706863882505, 0.456311852680773566, 0.460246417814923481,
+     0.464202689050278838, 0.468180961407822172, 0.472181538469883255, 0.476204732721683788,
+     0.480250865911249714, 0.484320269428911598, 0.488413284707712059, 0.492530263646148658,
+     0.496671569054796314, 0.500837575128482149, 0.505028667945828791, 0.509245245998136142,
+     0.513487720749743026, 0.517756517232200619, 0.522052074674794864, 0.526374847174186700,
+     0.530725304406193921, 0.535103932383019565, 0.539511234259544614, 0.543947731192649941,
+     0.548413963257921133, 0.552910490428519918, 0.557437893621486324, 0.561996775817277916,
+     0.566587763258951771, 0.571211506738074970, 0.575868682975210544, 0.580559996103683473,
+     0.585286179266300333, 0.590047996335791969, 0.594846243770991268, 0.599681752622167719,
+     0.604555390700549533, 0.609468064928895381, 0.614420723892076803, 0.619414360609039205,
+     0.624450015550274240, 0.629528779928128279, 0.634651799290960050, 0.639820277456438991,
+     0.645035480824251883, 0.650298743114294586, 0.655611470583224665, 0.660975147780241357,
+     0.666391343912380640, 0.671861719900766374, 0.677388036222513090, 0.682972161648791376,
+     0.688616083008527058, 0.694321916130032579, 0.700091918140490099, 0.705928501336797409,
+     0.711834248882358467, 0.717811932634901395, 0.723864533472881599, 0.729995264565802437,
+     0.736207598131266683, 0.742505296344636245, 0.748892447223726720, 0.755373506511754500,
+     0.761953346841546475, 0.768637315803334831, 0.775431304986138326, 0.782341832659861902,
+     0.789376143571198563, 0.796542330428254619, 0.803849483176389490, 0.811307874318219935,
+     0.818929191609414797, 0.826726833952094231, 0.834716292992930375, 0.842915653118441077,
+     0.851346258465123684, 0.860033621203008636, 0.869008688043793165, 0.878309655816146839,
+     0.887984660763399880, 0.898095921906304051, 0.908726440060562912, 0.919991505048360247,
+     0.932060075968990209, 0.945198953453078028, 0.959879091812415930, 0.977101701282731328,
+     1.000000000000000000];
+pub static ZIG_NORM_F_DIFF: [f64, .. 257] =
+    [0.000000000000000000, 0.000782818165911943, 0.001348786815607765, 0.001428899847265509,
+     0.001484430705892882, 0.001528472172127356, 0.001565707298030807, 0.001598388670308183,
+     0.001627786418212004, 0.001654692743837703, 0.001679637706201265, 0.001702994844613767,
+     0.001725038123187510, 0.001745974954326004, 0.001765966477270568, 0.001785140598493315,
+     0.001803600702759419, 0.001821431661060659, 0.001838704088536796, 0.001855477433793579,
+     0.001871802266665008, 0.001887722003144375, 0.001903274226858077, 0.001918491715965767,
+     0.001933403251421835, 0.001948034260540625, 0.001962407334827158, 0.001976542650643127,
+     0.001990458313945481, 0.002004170645086643, 0.002017694415851860, 0.002031043048104267,
+     0.002044228781321551, 0.002057262814738517, 0.002070155428613822, 0.002082916088226049,
+     0.002095553533492583, 0.002108075856553551, 0.002120490569226280, 0.002132804661891696,
+     0.002145024655099026, 0.002157156644953973, 0.002169206343177243, 0.002181179112575302,
+     0.002193079998548175, 0.002204913757158977, 0.002216684880213121, 0.002228397617726446,
+     0.002240055998106505, 0.002251663846325885, 0.002263224800326716, 0.002274742325862292,
+     0.002286219729956393, 0.002297660173134250, 0.002309066680560787, 0.002320442152205823,
+     0.002331789372137141, 0.002343111017035562, 0.002354409664009627, 0.002365687797781804,
+     0.002376947817308683, 0.002388192041889739, 0.002399422716815966, 0.002410642018598946,
+     0.002421852059823287, 0.002433054893654529, 0.002444252518034679, 0.002455446879594508,
+     0.002466639877306970, 0.002477833365903986, 0.002489029159078809, 0.002500229032490808,
+     0.002511434726590794, 0.002522647949281448, 0.002533870378427505, 0.002545103664226889,
+     0.002556349431455662, 0.002567609281597438, 0.002578884794865288, 0.002590177532127119,
+     0.002601489036740262, 0.002612820836305291, 0.002624174444343735, 0.002635551361907296,
+     0.002646953079123743, 0.002658381076686089, 0.002669836827288052, 0.002681321797012387,
+     0.002692837446676144, 0.002704385233135737, 0.002715966610556786, 0.002727583031652520,
+     0.002739235948893221, 0.002750926815690169, 0.002762657087557796, 0.002774428223256353,
+     0.002786241685917290, 0.002798098944155558, 0.002810001473169871, 0.002821950755833219,
+     0.002833948283778004, 0.002845995558475284, 0.002858094092312607, 0.002870245409671041,
+     0.002882451048004164, 0.002894712558920987, 0.002907031509275432, 0.002919409482262880,
+     0.002931848078526783, 0.002944348917277934, 0.002956913637427061, 0.002969543898733384,
+     0.002982241382970874, 0.002995007795115689, 0.003007844864553855, 0.003020754346314269,
+     0.003033738022328147, 0.003046797702715820, 0.003059935227105459, 0.003073152465984053,
+     0.003086451322084072, 0.003099833731808721, 0.003113301666695822, 0.003126857134927052,
+     0.003140502182881588, 0.003154238896738770, 0.003168069404132778, 0.003181995875862154,
+     0.003196020527657495, 0.003210145622009941, 0.003224373470066433, 0.003238706433592253,
+     0.003253146927007733, 0.003267697419501892, 0.003282360437226572, 0.003297138565578506,
+     0.003312034451571411, 0.003327050806304299, 0.003342190407532641, 0.003357456102345890,
+     0.003372850809960137, 0.003388377524629727, 0.003404039318688046, 0.003419839345721265,
+     0.003435780843885239, 0.003451867139373843, 0.003468101650046629, 0.003484487889225119,
+     0.003501029469670069, 0.003517730107746697, 0.003534593627793237, 0.003551623966702611,
+     0.003568825178730639, 0.003586201440546166, 0.003603757056536316, 0.003621496464384588,
+     0.003639424240937217, 0.003657545108379068, 0.003675863940735269, 0.003694385770723563,
+     0.003713115796977806, 0.003732059391668707, 0.003751222108547281, 0.003770609691440940,
+     0.003790228083232539, 0.003810083435355216, 0.003830182117840641, 0.003850530729957835,
+     0.003871136111486317, 0.003892005354668437, 0.003913145816891062, 0.003934565134149914,
+     0.003956271235355358, 0.003978272357543333, 0.004000577062061084, 0.004023194251800533,
+     0.004046133189565926, 0.004069403517661885, 0.004093015278800460, 0.004116978938436600,
+     0.004141305408647655, 0.004166006073685835, 0.004191092817346642, 0.004216578052307351,
+     0.004242474751606884, 0.004268796482457593, 0.004295557442594244, 0.004322772499391836,
+     0.004350457232007221, 0.004378627976825644, 0.004407301876525049, 0.004436496933105327,
+     0.004466232065271192, 0.004496527170598785, 0.004527403192966406, 0.004558882195791591,
+     0.004590987441673855, 0.004623743479123199, 0.004657176237135574, 0.004691313128472929,
+     0.004726183162616859, 0.004761817069491636, 0.004798247435199299, 0.004835508851176451,
+     0.004873638078381815, 0.004912674228345848, 0.004952658963181422, 0.004993636716962402,
+     0.005035654941235035, 0.005078764377854039, 0.005123019362831771, 0.005168478165478940,
+     0.005215203367812893, 0.005263262290042703, 0.005312727468930079, 0.005363677197016692,
+     0.005416196132139284, 0.005470375988385734, 0.005526316321746716, 0.005584125426278286,
+     0.005643921359735682, 0.005705833121505521, 0.005770002010457520, 0.005836583196307310,
+     0.005905747545561058, 0.005977683752542928, 0.006052600837980204, 0.006130731092920838,
+     0.006212333565464245, 0.006297698213369562, 0.006387150879090475, 0.006481059288027780,
+     0.006579840329791975, 0.006683968961788356, 0.006793989182803495, 0.006910527673723577,
+     0.007034310911336661, 0.007166186857056056, 0.007307152748134871, 0.007458391141830445,
+     0.007621317291194862, 0.007797642342679434, 0.007989459040836144, 0.008199360125510702,
+     0.008430605346682607, 0.008687362737884952, 0.008975066840784529, 0.009300967772353674,
+     0.009675004947253041, 0.010111261142904171, 0.010630518154258861, 0.011265064987797335,
+     0.012068570920629962, 0.013138877484087819, 0.014680138359337902, 0.017222609470315398,
+     0.022898298717268672];
+pub static ZIG_EXP_R: f64 = 7.697117470131050077;
+pub static ZIG_EXP_X: [f64, .. 257] =
+    [8.697117470131052741, 7.697117470131050077, 6.941033629377212577, 6.478378493832569696,
+     6.144164665772472667, 5.882144315795399869, 5.666410167454033697, 5.482890627526062488,
+     5.323090505754398016, 5.181487281301500047, 5.054288489981304089, 4.938777085901250530,
+     4.832939741025112035, 4.735242996601741083, 4.644491885420085175, 4.559737061707351380,
+     4.480211746528421912, 4.405287693473573185, 4.334443680317273007, 4.267242480277365857,
+     4.203313713735184365, 4.142340865664051464, 4.084051310408297830, 4.028208544647936762,
+     3.974606066673788796, 3.923062500135489739, 3.873417670399509127, 3.825529418522336744,
+     3.779270992411667862, 3.734528894039797375, 3.691201090237418825, 3.649195515760853770,
+     3.608428813128909507, 3.568825265648337020, 3.530315889129343354, 3.492837654774059608,
+     3.456332821132760191, 3.420748357251119920, 3.386035442460300970, 3.352149030900109405,
+     3.319047470970748037, 3.286692171599068679, 3.255047308570449882, 3.224079565286264160,
+     3.193757903212240290, 3.164053358025972873, 3.134938858084440394, 3.106389062339824481,
+     3.078380215254090224, 3.050890016615455114, 3.023897504455676621, 2.997382949516130601,
+     2.971327759921089662, 2.945714394895045718, 2.920526286512740821, 2.895747768600141825,
+     2.871364012015536371, 2.847360965635188812, 2.823725302450035279, 2.800444370250737780,
+     2.777506146439756574, 2.754899196562344610, 2.732612636194700073, 2.710636095867928752,
+     2.688959688741803689, 2.667573980773266573, 2.646469963151809157, 2.625639026797788489,
+     2.605072938740835564, 2.584763820214140750, 2.564704126316905253, 2.544886627111869970,
+     2.525304390037828028, 2.505950763528594027, 2.486819361740209455, 2.467904050297364815,
+     2.449198932978249754, 2.430698339264419694, 2.412396812688870629, 2.394289099921457886,
+     2.376370140536140596, 2.358635057409337321, 2.341079147703034380, 2.323697874390196372,
+     2.306486858283579799, 2.289441870532269441, 2.272558825553154804, 2.255833774367219213,
+     2.239262898312909034, 2.222842503111036816, 2.206569013257663858, 2.190438966723220027,
+     2.174449009937774679, 2.158595893043885994, 2.142876465399842001, 2.127287671317368289,
+     2.111826546019042183, 2.096490211801715020, 2.081275874393225145, 2.066180819490575526,
+     2.051202409468584786, 2.036338080248769611, 2.021585338318926173, 2.006941757894518563,
+     1.992404978213576650, 1.977972700957360441, 1.963642687789548313, 1.949412758007184943,
+     1.935280786297051359, 1.921244700591528076, 1.907302480018387536, 1.893452152939308242,
+     1.879691795072211180, 1.866019527692827973, 1.852433515911175554, 1.838931967018879954,
+     1.825513128903519799, 1.812175288526390649, 1.798916770460290859, 1.785735935484126014,
+     1.772631179231305643, 1.759600930889074766, 1.746643651946074405, 1.733757834985571566,
+     1.720942002521935299, 1.708194705878057773, 1.695514524101537912, 1.682900062917553896,
+     1.670349953716452118, 1.657862852574172763, 1.645437439303723659, 1.633072416535991334,
+     1.620766508828257901, 1.608518461798858379, 1.596327041286483395, 1.584191032532688892,
+     1.572109239386229707, 1.560080483527888084, 1.548103603714513499, 1.536177455041032092,
+     1.524300908219226258, 1.512472848872117082, 1.500692176842816750, 1.488957805516746058,
+     1.477268661156133867, 1.465623682245745352, 1.454021818848793446, 1.442462031972012504,
+     1.430943292938879674, 1.419464582769983219, 1.408024891569535697, 1.396623217917042137,
+     1.385258568263121992, 1.373929956328490576, 1.362636402505086775, 1.351376933258335189,
+     1.340150580529504643, 1.328956381137116560, 1.317793376176324749, 1.306660610415174117,
+     1.295557131686601027, 1.284481990275012642, 1.273434238296241139, 1.262412929069615330,
+     1.251417116480852521, 1.240445854334406572, 1.229498195693849105, 1.218573192208790124,
+     1.207669893426761121, 1.196787346088403092, 1.185924593404202199, 1.175080674310911677,
+     1.164254622705678921, 1.153445466655774743, 1.142652227581672841, 1.131873919411078511,
+     1.121109547701330200, 1.110358108727411031, 1.099618588532597308, 1.088889961938546813,
+     1.078171191511372307, 1.067461226479967662, 1.056759001602551429, 1.046063435977044209,
+     1.035373431790528542, 1.024687873002617211, 1.014005623957096480, 1.003325527915696735,
+     0.992646405507275897, 0.981967053085062602, 0.971286240983903260, 0.960602711668666509,
+     0.949915177764075969, 0.939222319955262286, 0.928522784747210395, 0.917815182070044311,
+     0.907098082715690257, 0.896370015589889935, 0.885629464761751528, 0.874874866291025066,
+     0.864104604811004484, 0.853317009842373353, 0.842510351810368485, 0.831682837734273206,
+     0.820832606554411814, 0.809957724057418282, 0.799056177355487174, 0.788125868869492430,
+     0.777164609759129710, 0.766170112735434672, 0.755139984181982249, 0.744071715500508102,
+     0.732962673584365398, 0.721810090308756203, 0.710611050909655040, 0.699362481103231959,
+     0.688061132773747808, 0.676703568029522584, 0.665286141392677943, 0.653804979847664947,
+     0.642255960424536365, 0.630634684933490286, 0.618936451394876075, 0.607156221620300030,
+     0.595288584291502887, 0.583327712748769489, 0.571267316532588332, 0.559100585511540626,
+     0.546820125163310577, 0.534417881237165604, 0.521885051592135052, 0.509211982443654398,
+     0.496388045518671162, 0.483401491653461857, 0.470239275082169006, 0.456886840931420235,
+     0.443327866073552401, 0.429543940225410703, 0.415514169600356364, 0.401214678896277765,
+     0.386617977941119573, 0.371692145329917234, 0.356399760258393816, 0.340696481064849122,
+     0.324529117016909452, 0.307832954674932158, 0.290527955491230394, 0.272513185478464703,
+     0.253658363385912022, 0.233790483059674731, 0.212671510630966620, 0.189958689622431842,
+     0.165127622564187282, 0.137304980940012589, 0.104838507565818778, 0.063852163815001570,
+     0.000000000000000000];
+pub static ZIG_EXP_F: [f64, .. 257] =
+    [0.000167066692307963, 0.000454134353841497, 0.000967269282327174, 0.001536299780301573,
+     0.002145967743718907, 0.002788798793574076, 0.003460264777836904, 0.004157295120833797,
+     0.004877655983542396, 0.005619642207205489, 0.006381905937319183, 0.007163353183634991,
+     0.007963077438017043, 0.008780314985808977, 0.009614413642502212, 0.010464810181029981,
+     0.011331013597834600, 0.012212592426255378, 0.013109164931254991, 0.014020391403181943,
+     0.014945968011691148, 0.015885621839973156, 0.016839106826039941, 0.017806200410911355,
+     0.018786700744696024, 0.019780424338009740, 0.020787204072578114, 0.021806887504283581,
+     0.022839335406385240, 0.023884420511558174, 0.024942026419731787, 0.026012046645134221,
+     0.027094383780955803, 0.028188948763978646, 0.029295660224637411, 0.030414443910466622,
+     0.031545232172893622, 0.032687963508959555, 0.033842582150874358, 0.035009037697397431,
+     0.036187284781931443, 0.037377282772959382, 0.038578995503074871, 0.039792391023374139,
+     0.041017441380414840, 0.042254122413316254, 0.043502413568888197, 0.044762297732943289,
+     0.046033761076175184, 0.047316792913181561, 0.048611385573379504, 0.049917534282706379,
+     0.051235237055126281, 0.052564494593071685, 0.053905310196046080, 0.055257689676697030,
+     0.056621641283742870, 0.057997175631200659, 0.059384305633420280, 0.060783046445479660,
+     0.062193415408541036, 0.063615431999807376, 0.065049117786753805, 0.066494496385339816,
+     0.067951593421936643, 0.069420436498728783, 0.070901055162371843, 0.072393480875708752,
+     0.073897746992364746, 0.075413888734058410, 0.076941943170480517, 0.078481949201606435,
+     0.080033947542319905, 0.081597980709237419, 0.083174093009632397, 0.084762330532368146,
+     0.086362741140756927, 0.087975374467270231, 0.089600281910032886, 0.091237516631040197,
+     0.092887133556043569, 0.094549189376055873, 0.096223742550432825, 0.097910853311492213,
+     0.099610583670637132, 0.101322997425953631, 0.103048160171257702, 0.104786139306570145,
+     0.106537004050001632, 0.108300825451033755, 0.110077676405185357, 0.111867631670056283,
+     0.113670767882744286, 0.115487163578633506, 0.117316899211555525, 0.119160057175327641,
+     0.121016721826674792, 0.122886979509545108, 0.124770918580830933, 0.126668629437510671,
+     0.128580204545228199, 0.130505738468330773, 0.132445327901387494, 0.134399071702213602,
+     0.136367070926428829, 0.138349428863580176, 0.140346251074862399, 0.142357645432472146,
+     0.144383722160634720, 0.146424593878344889, 0.148480375643866735, 0.150551185001039839,
+     0.152637142027442801, 0.154738369384468027, 0.156854992369365148, 0.158987138969314129,
+     0.161134939917591952, 0.163298528751901734, 0.165478041874935922, 0.167673618617250081,
+     0.169885401302527550, 0.172113535315319977, 0.174358169171353411, 0.176619454590494829,
+     0.178897546572478278, 0.181192603475496261, 0.183504787097767436, 0.185834262762197083,
+     0.188181199404254262, 0.190545769663195363, 0.192928149976771296, 0.195328520679563189,
+     0.197747066105098818, 0.200183974691911210, 0.202639439093708962, 0.205113656293837654,
+     0.207606827724221982, 0.210119159388988230, 0.212650861992978224, 0.215202151075378628,
+     0.217773247148700472, 0.220364375843359439, 0.222975768058120111, 0.225607660116683956,
+     0.228260293930716618, 0.230933917169627356, 0.233628783437433291, 0.236345152457059560,
+     0.239083290262449094, 0.241843469398877131, 0.244625969131892024, 0.247431075665327543,
+     0.250259082368862240, 0.253110290015629402, 0.255985007030415324, 0.258883549749016173,
+     0.261806242689362922, 0.264753418835062149, 0.267725419932044739, 0.270722596799059967,
+     0.273745309652802915, 0.276793928448517301, 0.279868833236972869, 0.282970414538780746,
+     0.286099073737076826, 0.289255223489677693, 0.292439288161892630, 0.295651704281261252,
+     0.298892921015581847, 0.302163400675693528, 0.305463619244590256, 0.308794066934560185,
+     0.312155248774179606, 0.315547685227128949, 0.318971912844957239, 0.322428484956089223,
+     0.325917972393556354, 0.329440964264136438, 0.332998068761809096, 0.336589914028677717,
+     0.340217149066780189, 0.343880444704502575, 0.347580494621637148, 0.351318016437483449,
+     0.355093752866787626, 0.358908472948750001, 0.362762973354817997, 0.366658079781514379,
+     0.370594648435146223, 0.374573567615902381, 0.378595759409581067, 0.382662181496010056,
+     0.386773829084137932, 0.390931736984797384, 0.395136981833290435, 0.399390684475231350,
+     0.403694012530530555, 0.408048183152032673, 0.412454465997161457, 0.416914186433003209,
+     0.421428728997616908, 0.425999541143034677, 0.430628137288459167, 0.435316103215636907,
+     0.440065100842354173, 0.444876873414548846, 0.449753251162755330, 0.454696157474615836,
+     0.459707615642138023, 0.464789756250426511, 0.469944825283960310, 0.475175193037377708,
+     0.480483363930454543, 0.485871987341885248, 0.491343869594032867, 0.496901987241549881,
+     0.502549501841348056, 0.508289776410643213, 0.514126393814748894, 0.520063177368233931,
+     0.526104213983620062, 0.532253880263043655, 0.538516872002862246, 0.544898237672440056,
+     0.551403416540641733, 0.558038282262587892, 0.564809192912400615, 0.571723048664826150,
+     0.578787358602845359, 0.586010318477268366, 0.593400901691733762, 0.600968966365232560,
+     0.608725382079622346, 0.616682180915207878, 0.624852738703666200, 0.633251994214366398,
+     0.641896716427266423, 0.650805833414571433, 0.660000841079000145, 0.669506316731925177,
+     0.679350572264765806, 0.689566496117078431, 0.700192655082788606, 0.711274760805076456,
+     0.722867659593572465, 0.735038092431424039, 0.747868621985195658, 0.761463388849896838,
+     0.775956852040116218, 0.791527636972496285, 0.808421651523009044, 0.826993296643051101,
+     0.847785500623990496, 0.871704332381204705, 0.900469929925747703, 0.938143680862176477,
+     1.000000000000000000];
+pub static ZIG_EXP_F_DIFF: [f64, .. 257] =
+    [0.000000000000000000, 0.000287067661533533, 0.000513134928485678, 0.000569030497974398,
+     0.000609667963417335, 0.000642831049855169, 0.000671465984262828, 0.000697030342996893,
+     0.000720360862708599, 0.000741986223663093, 0.000762263730113694, 0.000781447246315807,
+     0.000799724254382053, 0.000817237547791934, 0.000834098656693235, 0.000850396538527769,
+     0.000866203416804620, 0.000881578828420777, 0.000896572504999613, 0.000911226471926952,
+     0.000925576608509206, 0.000939653828282008, 0.000953484986066785, 0.000967093584871414,
+     0.000980500333784669, 0.000993723593313716, 0.001006779734568374, 0.001019683431705467,
+     0.001032447902101660, 0.001045085105172934, 0.001057605908173612, 0.001070020225402434,
+     0.001082337135821582, 0.001094564983022843, 0.001106711460658764, 0.001118783685829211,
+     0.001130788262427001, 0.001142731336065933, 0.001154618641914802, 0.001166455546523074,
+     0.001178247084534012, 0.001189997991027938, 0.001201712730115490, 0.001213395520299268,
+     0.001225050357040701, 0.001236681032901414, 0.001248291155571943, 0.001259884164055092,
+     0.001271463343231895, 0.001283031837006378, 0.001294592660197942, 0.001306148709326875,
+     0.001317702772419903, 0.001329257537945404, 0.001340815602974395, 0.001352379480650950,
+     0.001363951607045839, 0.001375534347457789, 0.001387130002219621, 0.001398740812059381,
+     0.001410368963061376, 0.001422016591266340, 0.001433685786946429, 0.001445378598586011,
+     0.001457097036596827, 0.001468843076792140, 0.001480618663643060, 0.001492425713336909,
+     0.001504266116655995, 0.001516141741693663, 0.001528054436422108, 0.001540006031125918,
+     0.001551998340713470, 0.001564033166917514, 0.001576112300394977, 0.001588237522735750,
+     0.001600410608388780, 0.001612633326513305, 0.001624907442762655, 0.001637234721007311,
+     0.001649616925003372, 0.001662055820012304, 0.001674553174376953, 0.001687110761059388,
+     0.001699730359144919, 0.001712413755316500, 0.001725162745304071, 0.001737979135312442,
+     0.001750864743431488, 0.001763821401032123, 0.001776850954151601, 0.001789955264870927,
+     0.001803136212688003, 0.001816395695889220, 0.001829735632922019, 0.001843157963772116,
+     0.001856664651347151, 0.001870257682870316, 0.001883939071285826, 0.001897710856679738,
+     0.001911575107717528, 0.001925533923102574, 0.001939589433056721, 0.001953743800826108,
+     0.001967999224215228, 0.001982357937151347, 0.001996822211282223, 0.002011394357609747,
+     0.002026076728162574, 0.002040871717710169, 0.002055781765521847, 0.002070809357173103,
+     0.002085957026402963, 0.002101227357025226, 0.002116622984897121, 0.002132146599948981,
+     0.002147800948277823, 0.002163588834309782, 0.002179513123034188, 0.002195576742314159,
+     0.002211782685277469, 0.002228134012792427, 0.002244633856033434, 0.002261285419141418,
+     0.002278091981983449, 0.002295056903017983, 0.002312183622271174, 0.002329475664429648,
+     0.002346936642057179, 0.002364570258941101, 0.002382380313575932, 0.002400370702791893,
+     0.002418545425535629, 0.002436908586812392, 0.002455464401797752, 0.002474217200128692,
+     0.002493171430384328, 0.002512331664766249, 0.002531702603989994, 0.002551289082400404,
+     0.002571096073321844, 0.002591128694658967, 0.002611392214760672, 0.002631892058563845,
+     0.002652633814032662, 0.002673623238910738, 0.002694866267805934, 0.002716369019626269,
+     0.002738137805389534, 0.002760179136428037, 0.002782499733014893, 0.002805106533435520,
+     0.002828006703534697, 0.002851207646767162, 0.002874717014785921, 0.002898542718600849,
+     0.002922692940346749, 0.002947176145699226, 0.002972001096982591, 0.002997176867015228,
+     0.003022712853742948, 0.003048618795714386, 0.003074904788455568, 0.003101581301807876,
+     0.003128659198296080, 0.003156149752600867, 0.003184064672214937, 0.003212416119368622,
+     0.003241216734320596, 0.003270479660111680, 0.003300218568896729, 0.003330447689969929,
+     0.003361181839619420, 0.003392436452949343, 0.003424227617828290, 0.003456572111131984,
+     0.003489487437467131, 0.003522991870580083, 0.003557104497672658, 0.003591845266868621,
+     0.003627235038102472, 0.003663295637722386, 0.003700049917134574, 0.003737521815846301,
+     0.003775736429304177, 0.003814720081962375, 0.003854500406067995, 0.003895106426696382,
+     0.003936568653631844, 0.003978919180756157, 0.004022191793678687, 0.004066422086428989,
+     0.004111647588127876, 0.004157907900659452, 0.004205244848493050, 0.004253702641940915,
+     0.004303328055299205, 0.004354170621502118, 0.004406282845128784, 0.004459720435841752,
+     0.004514542564613699, 0.004570812145417769, 0.004628596145424491, 0.004687965927177740,
+     0.004748997626717266, 0.004811772572194672, 0.004876377748206484, 0.004942906311860507,
+     0.005011458167522187, 0.005082140608288488, 0.005155069033533799, 0.005230367753417398,
+     0.005308170893076836, 0.005388623411430704, 0.005471882252147620, 0.005558117647517014,
+     0.005647514599798176, 0.005740274569295156, 0.005836617404105682, 0.005936783553485037,
+     0.006041036615386131, 0.006149666279423593, 0.006262991739818591, 0.006381365669577810,
+     0.006505178868201678, 0.006634865721946159, 0.006770910649812723, 0.006913855752425535,
+     0.007064309938019209, 0.007222959874423007, 0.007390583214465396, 0.007568064673498798,
+     0.007756415714389786, 0.007956798835585532, 0.008170557788458321, 0.008399255510700199,
+     0.008644722212900025, 0.008909116987305010, 0.009195007664428712, 0.009505475652925033,
+     0.009844255532840629, 0.010215923852312625, 0.010626158965710175, 0.011082105722287849,
+     0.011592898788496009, 0.012170432837851575, 0.012830529553771619, 0.013594766864701180,
+     0.014493463190219380, 0.015570784932380066, 0.016894014550512759, 0.018571645120042057,
+     0.020792203980939394, 0.023918831757214210, 0.028765597544542998, 0.037673750936428774,
+     0.061856319137823523];
diff --git a/src/libcore/repr.rs b/src/libcore/repr.rs
index abcb727809e..3d525993259 100644
--- a/src/libcore/repr.rs
+++ b/src/libcore/repr.rs
@@ -564,7 +564,7 @@ pub fn write_repr<T>(writer: @Writer, object: &T) {
     }
 }
 
-#[test]
+#[cfg(test)]
 struct P {a: int, b: float}
 
 #[test]
diff --git a/src/libcore/rt/context.rs b/src/libcore/rt/context.rs
index 4714be9e3d5..9c1e566f218 100644
--- a/src/libcore/rt/context.rs
+++ b/src/libcore/rt/context.rs
@@ -207,4 +207,3 @@ pub fn mut_offset<T>(ptr: *mut T, count: int) -> *mut T {
     use core::sys::size_of;
     (ptr as int + count * (size_of::<T>() as int)) as *mut T
 }
-
diff --git a/src/libcore/rt/io/comm_adapters.rs b/src/libcore/rt/io/comm_adapters.rs
index 1d6893b3ca6..7e891f1718e 100644
--- a/src/libcore/rt/io/comm_adapters.rs
+++ b/src/libcore/rt/io/comm_adapters.rs
@@ -56,4 +56,3 @@ impl<W: Writer> WriterChan<W> {
 impl<W: Writer> GenericChan<~[u8]> for WriterChan<W> {
     fn send(&self, _x: ~[u8]) { fail!() }
 }
-
diff --git a/src/libcore/rt/io/util.rs b/src/libcore/rt/io/extensions.rs
index cff224a80be..cff224a80be 100644
--- a/src/libcore/rt/io/util.rs
+++ b/src/libcore/rt/io/extensions.rs
diff --git a/src/libcore/rt/io/file.rs b/src/libcore/rt/io/file.rs
index e041183b584..85dc180452f 100644
--- a/src/libcore/rt/io/file.rs
+++ b/src/libcore/rt/io/file.rs
@@ -9,13 +9,9 @@
 // except according to those terms.
 
 use prelude::*;
-use super::misc::PathLike;
+use super::support::PathLike;
 use super::{Reader, Writer, Seek, Close};
-use super::{IoError, SeekStyle};
-
-/// Open a file with the default FileMode and FileAccess
-/// # XXX are there sane defaults here?
-pub fn open_file<P: PathLike>(_path: &P) -> FileStream { fail!() }
+use super::SeekStyle;
 
 /// # XXX
 /// * Ugh, this is ridiculous. What is the best way to represent these options?
@@ -46,7 +42,7 @@ impl FileStream {
     pub fn open<P: PathLike>(_path: &P,
                              _mode: FileMode,
                              _access: FileAccess
-                            ) -> Result<FileStream, IoError> {
+                            ) -> Option<FileStream> {
         fail!()
     }
 }
diff --git a/src/libcore/rt/io/mem.rs b/src/libcore/rt/io/mem.rs
index 600968a3c71..06e1466831d 100644
--- a/src/libcore/rt/io/mem.rs
+++ b/src/libcore/rt/io/mem.rs
@@ -17,7 +17,7 @@
 
 use prelude::*;
 use super::*;
-
+use cmp::min;
 
 /// Writes to an owned, growable byte vector
 pub struct MemWriter {
@@ -29,13 +29,15 @@ impl MemWriter {
 }
 
 impl Writer for MemWriter {
-    fn write(&mut self, _buf: &[u8]) { fail!() }
+    fn write(&mut self, buf: &[u8]) {
+        self.buf.push_all(buf)
+    }
 
     fn flush(&mut self) { /* no-op */ }
 }
 
 impl Seek for MemWriter {
-    fn tell(&self) -> u64 { fail!() }
+    fn tell(&self) -> u64 { self.buf.len() as u64 }
 
     fn seek(&mut self, _pos: i64, _style: SeekStyle) { fail!() }
 }
@@ -77,13 +79,27 @@ impl MemReader {
 }
 
 impl Reader for MemReader {
-    fn read(&mut self, _buf: &mut [u8]) -> Option<uint> { fail!() }
+    fn read(&mut self, buf: &mut [u8]) -> Option<uint> {
+        { if self.eof() { return None; } }
+
+        let write_len = min(buf.len(), self.buf.len() - self.pos);
+        {
+            let input = self.buf.slice(self.pos, self.pos + write_len);
+            let output = vec::mut_slice(buf, 0, write_len);
+            assert!(input.len() == output.len());
+            vec::bytes::copy_memory(output, input, write_len);
+        }
+        self.pos += write_len;
+        assert!(self.pos <= self.buf.len());
 
-    fn eof(&mut self) -> bool { fail!() }
+        return Some(write_len);
+    }
+
+    fn eof(&mut self) -> bool { self.pos == self.buf.len() }
 }
 
 impl Seek for MemReader {
-    fn tell(&self) -> u64 { fail!() }
+    fn tell(&self) -> u64 { self.pos as u64 }
 
     fn seek(&mut self, _pos: i64, _style: SeekStyle) { fail!() }
 }
@@ -163,4 +179,43 @@ impl<'self> Seek for BufReader<'self> {
     fn tell(&self) -> u64 { fail!() }
 
     fn seek(&mut self, _pos: i64, _style: SeekStyle) { fail!() }
-}
\ No newline at end of file
+}
+
+#[cfg(test)]
+mod test {
+    use prelude::*;
+    use super::*;
+
+    #[test]
+    fn test_mem_writer() {
+        let mut writer = MemWriter::new();
+        assert!(writer.tell() == 0);
+        writer.write([0]);
+        assert!(writer.tell() == 1);
+        writer.write([1, 2, 3]);
+        writer.write([4, 5, 6, 7]);
+        assert!(writer.tell() == 8);
+        assert!(writer.inner() == ~[0, 1, 2, 3, 4, 5 , 6, 7]);
+    }
+
+    #[test]
+    fn test_mem_reader() {
+        let mut reader = MemReader::new(~[0, 1, 2, 3, 4, 5, 6, 7]);
+        let mut buf = [];
+        assert!(reader.read(buf) == Some(0));
+        assert!(reader.tell() == 0);
+        let mut buf = [0];
+        assert!(reader.read(buf) == Some(1));
+        assert!(reader.tell() == 1);
+        assert!(buf == [0]);
+        let mut buf = [0, ..4];
+        assert!(reader.read(buf) == Some(4));
+        assert!(reader.tell() == 5);
+        assert!(buf == [1, 2, 3, 4]);
+        assert!(reader.read(buf) == Some(3));
+        assert!(buf.slice(0, 3) == [5, 6, 7]);
+        assert!(reader.eof());
+        assert!(reader.read(buf) == None);
+        assert!(reader.eof());
+    }
+}
diff --git a/src/libcore/rt/io/mod.rs b/src/libcore/rt/io/mod.rs
index cb00b02d9d1..97b3ee3e30e 100644
--- a/src/libcore/rt/io/mod.rs
+++ b/src/libcore/rt/io/mod.rs
@@ -11,7 +11,13 @@
 /*! Synchronous I/O
 
 This module defines the Rust interface for synchronous I/O.
-It supports file access,
+It models byte-oriented input and output with the Reader and Writer traits.
+Types that implement both `Reader` and `Writer` and called 'streams',
+and automatically implement trait `Stream`.
+Implementations are provided for common I/O streams like
+file, TCP, UDP, Unix domain sockets.
+Readers and Writers may be composed to add capabilities like string
+parsing, encoding, and compression.
 
 This will likely live in core::io, not core::rt::io.
 
@@ -27,44 +33,177 @@ Some examples of obvious things you might want to do
 
 * Read a complete file to a string, (converting newlines?)
 
-    let contents = open("message.txt").read_to_str(); // read_to_str??
+    let contents = File::open("message.txt").read_to_str(); // read_to_str??
 
 * Write a line to a file
 
-    let file = FileStream::open("message.txt", Create, Write);
+    let file = File::open("message.txt", Create, Write);
     file.write_line("hello, file!");
 
 * Iterate over the lines of a file
 
+    do File::open("message.txt").each_line |line| {
+        println(line)
+    }
+
 * Pull the lines of a file into a vector of strings
 
+    let lines = File::open("message.txt").line_iter().to_vec();
+
+* Make an simple HTTP request
+
+    let socket = TcpStream::open("localhost:8080");
+    socket.write_line("GET / HTTP/1.0");
+    socket.write_line("");
+    let response = socket.read_to_end();
+
 * Connect based on URL? Requires thinking about where the URL type lives
   and how to make protocol handlers extensible, e.g. the "tcp" protocol
   yields a `TcpStream`.
 
-    connect("tcp://localhost:8080").write_line("HTTP 1.0 GET /");
+    connect("tcp://localhost:8080");
 
 # Terms
 
-* reader
-* writer
-* stream
-* Blocking vs. non-blocking
-* synchrony and asynchrony
-
-I tend to call this implementation non-blocking, because performing I/O
-doesn't block the progress of other tasks. Is that how we want to present
-it, 'synchronous but non-blocking'?
+* Reader - An I/O source, reads bytes into a buffer
+* Writer - An I/O sink, writes bytes from a buffer
+* Stream - Typical I/O sources like files and sockets are both Readers and Writers,
+  and are collectively referred to a `streams`.
+* Decorator - A Reader or Writer that composes with others to add additional capabilities
+  such as encoding or decoding
+
+# Blocking and synchrony
+
+When discussing I/O you often hear the terms 'synchronous' and
+'asynchronous', along with 'blocking' and 'non-blocking' compared and
+contrasted. A synchronous I/O interface performs each I/O operation to
+completion before proceeding to the next. Synchronous interfaces are
+usually used in imperative style as a sequence of commands. An
+asynchronous interface allows multiple I/O requests to be issued
+simultaneously, without waiting for each to complete before proceeding
+to the next.
+
+Asynchronous interfaces are used to achieve 'non-blocking' I/O. In
+traditional single-threaded systems, performing a synchronous I/O
+operation means that the program stops all activity (it 'blocks')
+until the I/O is complete. Blocking is bad for performance when
+there are other computations that could be done.
+
+Asynchronous interfaces are most often associated with the callback
+(continuation-passing) style popularised by node.js. Such systems rely
+on all computations being run inside an event loop which maintains a
+list of all pending I/O events; when one completes the registered
+callback is run and the code that made the I/O request continiues.
+Such interfaces achieve non-blocking at the expense of being more
+difficult to reason about.
+
+Rust's I/O interface is synchronous - easy to read - and non-blocking by default.
+
+Remember that Rust tasks are 'green threads', lightweight threads that
+are multiplexed onto a single operating system thread. If that system
+thread blocks then no other task may proceed. Rust tasks are
+relatively cheap to create, so as long as other tasks are free to
+execute then non-blocking code may be written by simply creating a new
+task.
+
+When discussing blocking in regards to Rust's I/O model, we are
+concerned with whether performing I/O blocks other Rust tasks from
+proceeding. In other words, when a task calls `read`, it must then
+wait (or 'sleep', or 'block') until the call to `read` is complete.
+During this time, other tasks may or may not be executed, depending on
+how `read` is implemented.
+
+
+Rust's default I/O implementation is non-blocking; by cooperating
+directly with the task scheduler it arranges to never block progress
+of *other* tasks. Under the hood, Rust uses asynchronous I/O via a
+per-scheduler (and hence per-thread) event loop. Synchronous I/O
+requests are implemented by descheduling the running task and
+performing an asynchronous request; the task is only resumed once the
+asynchronous request completes.
+
+For blocking (but possibly more efficient) implementations, look
+in the `io::native` module.
 
 # Error Handling
 
+I/O is an area where nearly every operation can result in unexpected
+errors. It should allow errors to be handled efficiently.
+It needs to be convenient to use I/O when you don't care
+about dealing with specific errors.
+
+Rust's I/O employs a combination of techniques to reduce boilerplate
+while still providing feedback about errors. The basic strategy:
+
+* Errors are fatal by default, resulting in task failure
+* Errors raise the `io_error` conditon which provides an opportunity to inspect
+  an IoError object containing details.
+* Return values must have a sensible null or zero value which is returned
+  if a condition is handled successfully. This may be an `Option`, an empty
+  vector, or other designated error value.
+* Common traits are implemented for `Option`, e.g. `impl<R: Reader> Reader for Option<R>`,
+  so that nullable values do not have to be 'unwrapped' before use.
+
+These features combine in the API to allow for expressions like
+`File::new("diary.txt").write_line("met a girl")` without having to
+worry about whether "diary.txt" exists or whether the write
+succeeds. As written, if either `new` or `write_line` encounters
+an error the task will fail.
+
+If you wanted to handle the error though you might write
+
+    let mut error = None;
+    do io_error::cond(|e: IoError| {
+        error = Some(e);
+    }).in {
+        File::new("diary.txt").write_line("met a girl");
+    }
+
+    if error.is_some() {
+        println("failed to write my diary");
+    }
+
+XXX: Need better condition handling syntax
+
+In this case the condition handler will have the opportunity to
+inspect the IoError raised by either the call to `new` or the call to
+`write_line`, but then execution will continue.
+
+So what actually happens if `new` encounters an error? To understand
+that it's important to know that what `new` returns is not a `File`
+but an `Option<File>`.  If the file does not open, and the condition
+is handled, then `new` will simply return `None`. Because there is an
+implementation of `Writer` (the trait required ultimately required for
+types to implement `write_line`) there is no need to inspect or unwrap
+the `Option<File>` and we simply call `write_line` on it.  If `new`
+returned a `None` then the followup call to `write_line` will also
+raise an error.
+
+## Concerns about this strategy
+
+This structure will encourage a programming style that is prone
+to errors similar to null pointer dereferences.
+In particular code written to ignore errors and expect conditions to be unhandled
+will start passing around null or zero objects when wrapped in a condition handler.
+
+* XXX: How should we use condition handlers that return values?
+
+
+# Issues withi/o scheduler affinity, work stealing, task pinning
+
 # Resource management
 
 * `close` vs. RAII
 
-# Paths and URLs
+# Paths, URLs and overloaded constructors
+
+
+
+# Scope
 
-# std
+In scope for core
+
+* Url?
 
 Some I/O things don't belong in core
 
@@ -73,7 +212,12 @@ Some I/O things don't belong in core
     - http
   - flate
 
-# XXX
+Out of scope
+
+* Async I/O. We'll probably want it eventually
+
+
+# XXX Questions and issues
 
 * Should default constructors take `Path` or `&str`? `Path` makes simple cases verbose.
   Overloading would be nice.
@@ -83,6 +227,7 @@ Some I/O things don't belong in core
 * fsync
 * relationship with filesystem querying, Directory, File types etc.
 * Rename Reader/Writer to ByteReader/Writer, make Reader/Writer generic?
+* Can Port and Chan be implementations of a generic Reader<T>/Writer<T>?
 * Trait for things that are both readers and writers, Stream?
 * How to handle newline conversion
 * String conversion
@@ -92,6 +237,7 @@ Some I/O things don't belong in core
 * Do we need `close` at all? dtors might be good enough
 * How does I/O relate to the Iterator trait?
 * std::base64 filters
+* Using conditions is a big unknown since we don't have much experience with them
 
 */
 
@@ -104,25 +250,29 @@ pub use self::stdio::stderr;
 pub use self::stdio::print;
 pub use self::stdio::println;
 
-pub use self::file::open_file;
 pub use self::file::FileStream;
-pub use self::net::Listener;
 pub use self::net::ip::IpAddr;
 pub use self::net::tcp::TcpListener;
 pub use self::net::tcp::TcpStream;
 pub use self::net::udp::UdpStream;
 
 // Some extension traits that all Readers and Writers get.
-pub use self::util::ReaderUtil;
-pub use self::util::ReaderByteConversions;
-pub use self::util::WriterByteConversions;
+pub use self::extensions::ReaderUtil;
+pub use self::extensions::ReaderByteConversions;
+pub use self::extensions::WriterByteConversions;
 
 /// Synchronous, non-blocking file I/O.
 pub mod file;
 
 /// Synchronous, non-blocking network I/O.
-#[path = "net/mod.rs"]
-pub mod net;
+pub mod net {
+    pub mod tcp;
+    pub mod udp;
+    pub mod ip;
+    #[cfg(unix)]
+    pub mod unix;
+    pub mod http;
+}
 
 /// Readers and Writers for memory buffers and strings.
 pub mod mem;
@@ -130,6 +280,10 @@ pub mod mem;
 /// Non-blocking access to stdin, stdout, stderr
 pub mod stdio;
 
+/// Implementations for Option
+#[cfg(not(stage0))] // Requires condition! fixes
+mod option;
+
 /// Basic stream compression. XXX: Belongs with other flate code
 pub mod flate;
 
@@ -137,10 +291,10 @@ pub mod flate;
 pub mod comm_adapters;
 
 /// Extension traits
-mod util;
+mod extensions;
 
 /// Non-I/O things needed by the I/O module
-mod misc;
+mod support;
 
 /// Thread-blocking implementations
 pub mod native {
@@ -170,12 +324,14 @@ pub struct IoError {
     detail: Option<~str>
 }
 
+#[deriving(Eq)]
 pub enum IoErrorKind {
     FileNotFound,
     FilePermission,
     ConnectionFailed,
     Closed,
-    OtherIoError
+    OtherIoError,
+    PreviousIoError
 }
 
 // XXX: Can't put doc comments on macros
@@ -208,9 +364,9 @@ pub trait Reader {
     ///         println(reader.read_line());
     ///     }
     ///
-    /// # XXX
+    /// # Failue
     ///
-    /// What does this return if the Reader is in an error state?
+    /// Returns `true` on failure.
     fn eof(&mut self) -> bool;
 }
 
@@ -250,9 +406,30 @@ pub enum SeekStyle {
 /// * Are `u64` and `i64` the right choices?
 pub trait Seek {
     fn tell(&self) -> u64;
+
+    /// Seek to an offset in a stream
+    ///
+    /// A successful seek clears the EOF indicator.
+    ///
+    /// # XXX
+    ///
+    /// * What is the behavior when seeking past the end of a stream?
     fn seek(&mut self, pos: i64, style: SeekStyle);
 }
 
+/// A listener is a value that listens for connections
+pub trait Listener<S> {
+    /// Wait for and accept an incoming connection
+    ///
+    /// Returns `None` on timeout.
+    ///
+    /// # Failure
+    ///
+    /// Raises `io_error` condition. If the condition is handled,
+    /// then `accept` returns `None`.
+    fn accept(&mut self) -> Option<S>;
+}
+
 /// Common trait for decorator types.
 ///
 /// Provides accessors to get the inner, 'decorated' values. The I/O library
@@ -278,3 +455,16 @@ pub trait Decorator<T> {
     /// Take a mutable reference to the decorated value
     fn inner_mut_ref<'a>(&'a mut self) -> &'a mut T;
 }
+
+pub fn standard_error(kind: IoErrorKind) -> IoError {
+    match kind {
+        PreviousIoError => {
+            IoError {
+                kind: PreviousIoError,
+                desc: "Failing due to a previous I/O error",
+                detail: None
+            }
+        }
+        _ => fail!()
+    }
+}
diff --git a/src/libcore/rt/io/net/ip.rs b/src/libcore/rt/io/net/ip.rs
index d9b7f4e6e40..df1dfe4d38a 100644
--- a/src/libcore/rt/io/net/ip.rs
+++ b/src/libcore/rt/io/net/ip.rs
@@ -12,4 +12,3 @@ pub enum IpAddr {
     Ipv4(u8, u8, u8, u8, u16),
     Ipv6
 }
-
diff --git a/src/libcore/rt/io/net/tcp.rs b/src/libcore/rt/io/net/tcp.rs
index e3f71dca8c8..c95b4344fe7 100644
--- a/src/libcore/rt/io/net/tcp.rs
+++ b/src/libcore/rt/io/net/tcp.rs
@@ -9,14 +9,13 @@
 // except according to those terms.
 
 use prelude::*;
-use super::*;
 use super::super::*;
 use super::ip::IpAddr;
 
 pub struct TcpStream;
 
 impl TcpStream {
-    pub fn connect(_addr: IpAddr) -> Result<TcpStream, IoError> {
+    pub fn connect(_addr: IpAddr) -> Option<TcpStream> {
         fail!()
     }
 }
@@ -40,7 +39,7 @@ impl Close for TcpStream {
 pub struct TcpListener;
 
 impl TcpListener {
-    pub fn new(_addr: IpAddr) -> TcpListener {
+    pub fn bind(_addr: IpAddr) -> Option<TcpListener> {
         fail!()
     }
 }
@@ -48,3 +47,28 @@ impl TcpListener {
 impl Listener<TcpStream> for TcpListener {
     fn accept(&mut self) -> Option<TcpStream> { fail!() }
 }
+
+#[cfg(test)]
+mod test {
+
+    #[test] #[ignore]
+    fn smoke_test() {
+        /*do run_in_newsched_task {
+            let addr = next_test_ip4();
+
+            do spawn_immediately {
+                let listener = TcpListener::bind(addr);
+                do listener.accept() {
+                    let mut buf = [0];
+                    listener.read(buf);
+                    assert!(buf[0] == 99);
+                }
+            }
+
+            do spawn_immediately {
+                let stream = TcpStream::connect(addr);
+                stream.write([99]);
+            }
+        }*/
+    }
+}
diff --git a/src/libcore/rt/io/net/udp.rs b/src/libcore/rt/io/net/udp.rs
index f76bb58a45e..1f1254a7029 100644
--- a/src/libcore/rt/io/net/udp.rs
+++ b/src/libcore/rt/io/net/udp.rs
@@ -9,14 +9,13 @@
 // except according to those terms.
 
 use prelude::*;
-use super::*;
 use super::super::*;
 use super::ip::IpAddr;
 
 pub struct UdpStream;
 
 impl UdpStream {
-    pub fn connect(_addr: IpAddr) -> Result<UdpStream, IoError> {
+    pub fn connect(_addr: IpAddr) -> Option<UdpStream> {
         fail!()
     }
 }
@@ -40,7 +39,7 @@ impl Close for UdpStream {
 pub struct UdpListener;
 
 impl UdpListener {
-    pub fn new(_addr: IpAddr) -> UdpListener {
+    pub fn bind(_addr: IpAddr) -> Option<UdpListener> {
         fail!()
     }
 }
@@ -48,4 +47,3 @@ impl UdpListener {
 impl Listener<UdpStream> for UdpListener {
     fn accept(&mut self) -> Option<UdpStream> { fail!() }
 }
-
diff --git a/src/libcore/rt/io/net/unix.rs b/src/libcore/rt/io/net/unix.rs
index 35eabe21b2a..f449a857467 100644
--- a/src/libcore/rt/io/net/unix.rs
+++ b/src/libcore/rt/io/net/unix.rs
@@ -9,14 +9,13 @@
 // except according to those terms.
 
 use prelude::*;
-use super::*;
 use super::super::*;
-use super::super::misc::PathLike;
+use super::super::support::PathLike;
 
 pub struct UnixStream;
 
 impl UnixStream {
-    pub fn connect<P: PathLike>(_path: &P) -> Result<UnixStream, IoError> {
+    pub fn connect<P: PathLike>(_path: &P) -> Option<UnixStream> {
         fail!()
     }
 }
@@ -40,7 +39,7 @@ impl Close for UnixStream {
 pub struct UnixListener;
 
 impl UnixListener {
-    pub fn new<P: PathLike>(_path: &P) -> UnixListener {
+    pub fn bind<P: PathLike>(_path: &P) -> Option<UnixListener> {
         fail!()
     }
 }
@@ -48,4 +47,3 @@ impl UnixListener {
 impl Listener<UnixStream> for UnixListener {
     fn accept(&mut self) -> Option<UnixStream> { fail!() }
 }
-
diff --git a/src/libcore/rt/io/option.rs b/src/libcore/rt/io/option.rs
new file mode 100644
index 00000000000..95f8711cb5b
--- /dev/null
+++ b/src/libcore/rt/io/option.rs
@@ -0,0 +1,153 @@
+// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+//! Implementations of I/O traits for the Option type
+//!
+//! I/O constructors return option types to allow errors to be handled.
+//! These implementations allow e.g. `Option<FileStream>` to be used
+//! as a `Reader` without unwrapping the option first.
+//!
+//! # XXX Seek and Close
+
+use option::*;
+use super::{Reader, Writer, Listener};
+use super::{standard_error, PreviousIoError, io_error, IoError};
+
+fn prev_io_error() -> IoError {
+    standard_error(PreviousIoError)
+}
+
+impl<W: Writer> Writer for Option<W> {
+    fn write(&mut self, buf: &[u8]) {
+        match *self {
+            Some(ref mut writer) => writer.write(buf),
+            None => io_error::cond.raise(prev_io_error())
+        }
+    }
+
+    fn flush(&mut self) {
+        match *self {
+            Some(ref mut writer) => writer.flush(),
+            None => io_error::cond.raise(prev_io_error())
+        }
+    }
+}
+
+impl<R: Reader> Reader for Option<R> {
+    fn read(&mut self, buf: &mut [u8]) -> Option<uint> {
+        match *self {
+            Some(ref mut reader) => reader.read(buf),
+            None => {
+                io_error::cond.raise(prev_io_error());
+                None
+            }
+        }
+    }
+
+    fn eof(&mut self) -> bool {
+        match *self {
+            Some(ref mut reader) => reader.eof(),
+            None => {
+                io_error::cond.raise(prev_io_error());
+                true
+            }
+        }
+    }
+}
+
+impl<L: Listener<S>, S> Listener<S> for Option<L> {
+    fn accept(&mut self) -> Option<S> {
+        match *self {
+            Some(ref mut listener) => listener.accept(),
+            None => {
+                io_error::cond.raise(prev_io_error());
+                None
+            }
+        }
+    }
+}
+
+#[cfg(test)]
+mod test {
+    use option::*;
+    use super::super::mem::*;
+    use rt::test::*;
+    use super::super::{PreviousIoError, io_error};
+
+    #[test]
+    fn test_option_writer() {
+        do run_in_newsched_task {
+            let mut writer: Option<MemWriter> = Some(MemWriter::new());
+            writer.write([0, 1, 2]);
+            writer.flush();
+            assert!(writer.unwrap().inner() == ~[0, 1, 2]);
+        }
+    }
+
+    #[test]
+    fn test_option_writer_error() {
+        do run_in_newsched_task {
+            let mut writer: Option<MemWriter> = None;
+
+            let mut called = false;
+            do io_error::cond.trap(|err| {
+                assert!(err.kind == PreviousIoError);
+                called = true;
+            }).in {
+                writer.write([0, 0, 0]);
+            }
+            assert!(called);
+
+            let mut called = false;
+            do io_error::cond.trap(|err| {
+                assert!(err.kind == PreviousIoError);
+                called = true;
+            }).in {
+                writer.flush();
+            }
+            assert!(called);
+        }
+    }
+
+    #[test]
+    fn test_option_reader() {
+        do run_in_newsched_task {
+            let mut reader: Option<MemReader> = Some(MemReader::new(~[0, 1, 2, 3]));
+            let mut buf = [0, 0];
+            reader.read(buf);
+            assert!(buf == [0, 1]);
+            assert!(!reader.eof());
+        }
+    }
+
+    #[test]
+    fn test_option_reader_error() {
+        let mut reader: Option<MemReader> = None;
+        let mut buf = [];
+
+        let mut called = false;
+        do io_error::cond.trap(|err| {
+            assert!(err.kind == PreviousIoError);
+            called = true;
+        }).in {
+            reader.read(buf);
+        }
+        assert!(called);
+
+        let mut called = false;
+        do io_error::cond.trap(|err| {
+            assert!(err.kind == PreviousIoError);
+            called = true;
+        }).in {
+            assert!(reader.eof());
+        }
+        assert!(called);
+    }
+}
diff --git a/src/libcore/rt/io/misc.rs b/src/libcore/rt/io/support.rs
index 7bace5d6df2..7bace5d6df2 100644
--- a/src/libcore/rt/io/misc.rs
+++ b/src/libcore/rt/io/support.rs
diff --git a/src/libcore/rt/local_heap.rs b/src/libcore/rt/local_heap.rs
new file mode 100644
index 00000000000..6bf228a1b22
--- /dev/null
+++ b/src/libcore/rt/local_heap.rs
@@ -0,0 +1,80 @@
+// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+//! The local, garbage collected heap
+
+use libc::{c_void, uintptr_t, size_t};
+use ops::Drop;
+
+type MemoryRegion = c_void;
+type BoxedRegion = c_void;
+
+pub type OpaqueBox = c_void;
+pub type TypeDesc = c_void;
+
+pub struct LocalHeap {
+    memory_region: *MemoryRegion,
+    boxed_region: *BoxedRegion
+}
+
+impl LocalHeap {
+    pub fn new() -> LocalHeap {
+        unsafe {
+            // Don't need synchronization for the single-threaded local heap
+            let synchronized = false as uintptr_t;
+            // XXX: These usually come from the environment
+            let detailed_leaks = false as uintptr_t;
+            let poison_on_free = false as uintptr_t;
+            let region = rust_new_memory_region(synchronized, detailed_leaks, poison_on_free);
+            assert!(region.is_not_null());
+            let boxed = rust_new_boxed_region(region, poison_on_free);
+            assert!(boxed.is_not_null());
+            LocalHeap {
+                memory_region: region,
+                boxed_region: boxed
+            }
+        }
+    }
+
+    pub fn alloc(&mut self, td: *TypeDesc, size: uint) -> *OpaqueBox {
+        unsafe {
+            return rust_boxed_region_malloc(self.boxed_region, td, size as size_t);
+        }
+    }
+
+    pub fn free(&mut self, box: *OpaqueBox) {
+        unsafe {
+            return rust_boxed_region_free(self.boxed_region, box);
+        }
+    }
+}
+
+impl Drop for LocalHeap {
+    fn finalize(&self) {
+        unsafe {
+            rust_delete_boxed_region(self.boxed_region);
+            rust_delete_memory_region(self.memory_region);
+        }
+    }
+}
+
+extern {
+    fn rust_new_memory_region(synchronized: uintptr_t,
+                               detailed_leaks: uintptr_t,
+                               poison_on_free: uintptr_t) -> *MemoryRegion;
+    fn rust_delete_memory_region(region: *MemoryRegion);
+    fn rust_new_boxed_region(region: *MemoryRegion,
+                             poison_on_free: uintptr_t) -> *BoxedRegion;
+    fn rust_delete_boxed_region(region: *BoxedRegion);
+    fn rust_boxed_region_malloc(region: *BoxedRegion,
+                                td: *TypeDesc,
+                                size: size_t) -> *OpaqueBox;
+    fn rust_boxed_region_free(region: *BoxedRegion, box: *OpaqueBox);
+}
diff --git a/src/libcore/rt/local_services.rs b/src/libcore/rt/local_services.rs
new file mode 100644
index 00000000000..a03bc6c409f
--- /dev/null
+++ b/src/libcore/rt/local_services.rs
@@ -0,0 +1,223 @@
+// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+//! Language-level runtime services that should reasonably expected
+//! to be available 'everywhere'. Local heaps, GC, unwinding,
+//! local storage, and logging. Even a 'freestanding' Rust would likely want
+//! to implement this.
+
+//! Local services may exist in at least three different contexts:
+//! when running as a task, when running in the scheduler's context,
+//! or when running outside of a scheduler but with local services
+//! (freestanding rust with local services?).
+
+use prelude::*;
+use libc::{c_void, uintptr_t};
+use cast::transmute;
+use super::sched::local_sched;
+use super::local_heap::LocalHeap;
+
+pub struct LocalServices {
+    heap: LocalHeap,
+    gc: GarbageCollector,
+    storage: LocalStorage,
+    logger: Logger,
+    unwinder: Option<Unwinder>,
+    destroyed: bool
+}
+
+pub struct GarbageCollector;
+pub struct LocalStorage(*c_void, Option<~fn(*c_void)>);
+pub struct Logger;
+
+pub struct Unwinder {
+    unwinding: bool,
+}
+
+impl LocalServices {
+    pub fn new() -> LocalServices {
+        LocalServices {
+            heap: LocalHeap::new(),
+            gc: GarbageCollector,
+            storage: LocalStorage(ptr::null(), None),
+            logger: Logger,
+            unwinder: Some(Unwinder { unwinding: false }),
+            destroyed: false
+        }
+    }
+
+    pub fn without_unwinding() -> LocalServices {
+        LocalServices {
+            heap: LocalHeap::new(),
+            gc: GarbageCollector,
+            storage: LocalStorage(ptr::null(), None),
+            logger: Logger,
+            unwinder: None,
+            destroyed: false
+        }
+    }
+
+    pub fn run(&mut self, f: &fn()) {
+        // This is just an assertion that `run` was called unsafely
+        // and this instance of LocalServices is still accessible.
+        do borrow_local_services |sched| {
+            assert!(ptr::ref_eq(sched, self));
+        }
+
+        match self.unwinder {
+            Some(ref mut unwinder) => {
+                // If there's an unwinder then set up the catch block
+                unwinder.try(f);
+            }
+            None => {
+                // Otherwise, just run the body
+                f()
+            }
+        }
+        self.destroy();
+    }
+
+    /// Must be called manually before finalization to clean up
+    /// thread-local resources. Some of the routines here expect
+    /// LocalServices to be available recursively so this must be
+    /// called unsafely, without removing LocalServices from
+    /// thread-local-storage.
+    fn destroy(&mut self) {
+        // This is just an assertion that `destroy` was called unsafely
+        // and this instance of LocalServices is still accessible.
+        do borrow_local_services |sched| {
+            assert!(ptr::ref_eq(sched, self));
+        }
+        match self.storage {
+            LocalStorage(ptr, Some(ref dtor)) => {
+                (*dtor)(ptr)
+            }
+            _ => ()
+        }
+        self.destroyed = true;
+    }
+}
+
+impl Drop for LocalServices {
+    fn finalize(&self) { assert!(self.destroyed) }
+}
+
+// Just a sanity check to make sure we are catching a Rust-thrown exception
+static UNWIND_TOKEN: uintptr_t = 839147;
+
+impl Unwinder {
+    pub fn try(&mut self, f: &fn()) {
+        use sys::Closure;
+
+        unsafe {
+            let closure: Closure = transmute(f);
+            let code = transmute(closure.code);
+            let env = transmute(closure.env);
+
+            let token = rust_try(try_fn, code, env);
+            assert!(token == 0 || token == UNWIND_TOKEN);
+        }
+
+        extern fn try_fn(code: *c_void, env: *c_void) {
+            unsafe {
+                let closure: Closure = Closure {
+                    code: transmute(code),
+                    env: transmute(env),
+                };
+                let closure: &fn() = transmute(closure);
+                closure();
+            }
+        }
+
+        extern {
+            #[rust_stack]
+            fn rust_try(f: *u8, code: *c_void, data: *c_void) -> uintptr_t;
+        }
+    }
+
+    pub fn begin_unwind(&mut self) -> ! {
+        self.unwinding = true;
+        unsafe {
+            rust_begin_unwind(UNWIND_TOKEN);
+            return transmute(());
+        }
+        extern {
+            fn rust_begin_unwind(token: uintptr_t);
+        }
+    }
+}
+
+/// Borrow a pointer to the installed local services.
+/// Fails (likely aborting the process) if local services are not available.
+pub fn borrow_local_services(f: &fn(&mut LocalServices)) {
+    do local_sched::borrow |sched| {
+        match sched.current_task {
+            Some(~ref mut task) => {
+                f(&mut task.local_services)
+            }
+            None => {
+                fail!(~"no local services for schedulers yet")
+            }
+        }
+    }
+}
+
+pub unsafe fn unsafe_borrow_local_services() -> &mut LocalServices {
+    use cast::transmute_mut_region;
+
+    match local_sched::unsafe_borrow().current_task {
+        Some(~ref mut task) => {
+            transmute_mut_region(&mut task.local_services)
+        }
+        None => {
+            fail!(~"no local services for schedulers yet")
+        }
+    }
+}
+
+#[cfg(test)]
+mod test {
+    use rt::test::*;
+
+    #[test]
+    fn local_heap() {
+        do run_in_newsched_task() {
+            let a = @5;
+            let b = a;
+            assert!(*a == 5);
+            assert!(*b == 5);
+        }
+    }
+
+    #[test]
+    fn tls() {
+        use task::local_data::*;
+        do run_in_newsched_task() {
+            unsafe {
+                fn key(_x: @~str) { }
+                local_data_set(key, @~"data");
+                assert!(*local_data_get(key).get() == ~"data");
+                fn key2(_x: @~str) { }
+                local_data_set(key2, @~"data");
+                assert!(*local_data_get(key2).get() == ~"data");
+            }
+        }
+    }
+
+    #[test]
+    fn unwind() {
+        do run_in_newsched_task() {
+            let result = spawntask_try(||());
+            assert!(result.is_ok());
+            let result = spawntask_try(|| fail!());
+            assert!(result.is_err());
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/libcore/rt/mod.rs b/src/libcore/rt/mod.rs
index e77ec82637e..a072fccd33d 100644
--- a/src/libcore/rt/mod.rs
+++ b/src/libcore/rt/mod.rs
@@ -8,30 +8,12 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+/*! The Rust runtime, including the scheduler and I/O interface */
+
 #[doc(hidden)];
 
 use libc::c_char;
 
-// Some basic logging
-macro_rules! rtdebug_ (
-    ($( $arg:expr),+) => ( {
-        dumb_println(fmt!( $($arg),+ ));
-
-        fn dumb_println(s: &str) {
-            use io::WriterUtil;
-            let dbg = ::libc::STDERR_FILENO as ::io::fd_t;
-            dbg.write_str(s);
-            dbg.write_str("\n");
-        }
-
-    } )
-)
-
-// An alternate version with no output, for turning off logging
-macro_rules! rtdebug (
-    ($( $arg:expr),+) => ( $(let _ = $arg)*; )
-)
-
 #[path = "sched/mod.rs"]
 mod sched;
 mod rtio;
@@ -48,6 +30,12 @@ mod stack;
 mod context;
 mod thread;
 pub mod env;
+pub mod local_services;
+mod local_heap;
+
+/// Tools for testing the runtime
+#[cfg(test)]
+pub mod test;
 
 pub fn start(main: *u8, _argc: int, _argv: **c_char, _crate_map: *u8) -> int {
     use self::sched::{Scheduler, Task};
@@ -72,7 +60,7 @@ pub fn start(main: *u8, _argc: int, _argv: **c_char, _crate_map: *u8) -> int {
 /// Different runtime services are available depending on context.
 #[deriving(Eq)]
 pub enum RuntimeContext {
-    // Only default services, e.g. exchange heap
+    // Only the exchange heap is available
     GlobalContext,
     // The scheduler may be accessed
     SchedulerContext,
@@ -139,24 +127,3 @@ fn test_context() {
         sched.run();
     }
 }
-
-// For setting up tests of the new scheduler
-#[cfg(test)]
-pub fn run_in_newsched_task(f: ~fn()) {
-    use cell::Cell;
-    use unstable::run_in_bare_thread;
-    use self::sched::Task;
-    use self::uvio::UvEventLoop;
-
-    let f = Cell(Cell(f));
-
-    do run_in_bare_thread {
-        let mut sched = ~UvEventLoop::new_scheduler();
-        let f = f.take();
-        let task = ~do Task::new(&mut sched.stack_pool) {
-            (f.take())();
-        };
-        sched.task_queue.push_back(task);
-        sched.run();
-    }
-}
diff --git a/src/libcore/rt/sched/local_sched.rs b/src/libcore/rt/sched/local_sched.rs
index 2d1e06163be..a7e02f30e01 100644
--- a/src/libcore/rt/sched/local_sched.rs
+++ b/src/libcore/rt/sched/local_sched.rs
@@ -143,4 +143,3 @@ fn borrow_smoke_test() {
     }
     let _scheduler = take();
 }
-
diff --git a/src/libcore/rt/sched/mod.rs b/src/libcore/rt/sched/mod.rs
index 333146394ee..663fe3e62d0 100644
--- a/src/libcore/rt/sched/mod.rs
+++ b/src/libcore/rt/sched/mod.rs
@@ -16,6 +16,7 @@ use super::work_queue::WorkQueue;
 use super::stack::{StackPool, StackSegment};
 use super::rtio::{EventLoop, EventLoopObject};
 use super::context::Context;
+use super::local_services::LocalServices;
 use cell::Cell;
 
 #[cfg(test)] use super::uvio::UvEventLoop;
@@ -38,7 +39,7 @@ pub struct Scheduler {
     /// Always valid when a task is executing, otherwise not
     priv saved_context: Context,
     /// The currently executing task
-    priv current_task: Option<~Task>,
+    current_task: Option<~Task>,
     /// An action performed after a context switch on behalf of the
     /// code running before the context switch
     priv cleanup_job: Option<CleanupJob>
@@ -147,7 +148,7 @@ pub impl Scheduler {
             }
         }
 
-        // Control never reaches here
+        abort!("control reached end of task");
     }
 
     fn schedule_new_task(~self, task: ~Task) {
@@ -324,10 +325,18 @@ pub struct Task {
     /// These are always valid when the task is not running, unless
     /// the task is dead
     priv saved_context: Context,
+    /// The heap, GC, unwinding, local storage, logging
+    local_services: LocalServices
 }
 
 pub impl Task {
     fn new(stack_pool: &mut StackPool, start: ~fn()) -> Task {
+        Task::with_local(stack_pool, LocalServices::new(), start)
+    }
+
+    fn with_local(stack_pool: &mut StackPool,
+                  local_services: LocalServices,
+                  start: ~fn()) -> Task {
         let start = Task::build_start_wrapper(start);
         let mut stack = stack_pool.take_segment(TASK_MIN_STACK_SIZE);
         // NB: Context holds a pointer to that ~fn
@@ -335,6 +344,7 @@ pub impl Task {
         return Task {
             current_stack_segment: stack,
             saved_context: initial_context,
+            local_services: local_services
         };
     }
 
@@ -347,9 +357,12 @@ pub impl Task {
             unsafe {
                 let sched = local_sched::unsafe_borrow();
                 sched.run_cleanup_job();
-            }
 
-            start();
+                let sched = local_sched::unsafe_borrow();
+                let task = sched.current_task.get_mut_ref();
+                // FIXME #6141: shouldn't neet to put `start()` in another closure
+                task.local_services.run(||start());
+            }
 
             let sched = local_sched::take();
             sched.terminate_current_task();
diff --git a/src/libcore/rt/test.rs b/src/libcore/rt/test.rs
new file mode 100644
index 00000000000..63db7054088
--- /dev/null
+++ b/src/libcore/rt/test.rs
@@ -0,0 +1,120 @@
+// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use cell::Cell;
+use result::{Result, Ok, Err};
+use super::io::net::ip::{IpAddr, Ipv4};
+use rt::local_services::LocalServices;
+
+/// Creates a new scheduler in a new thread and runs a task in it,
+/// then waits for the scheduler to exit. Failure of the task
+/// will abort the process.
+pub fn run_in_newsched_task(f: ~fn()) {
+    use unstable::run_in_bare_thread;
+    use super::sched::Task;
+    use super::uvio::UvEventLoop;
+
+    let f = Cell(f);
+
+    do run_in_bare_thread {
+        let mut sched = ~UvEventLoop::new_scheduler();
+        let task = ~Task::with_local(&mut sched.stack_pool,
+                                     LocalServices::without_unwinding(),
+                                     f.take());
+        sched.task_queue.push_back(task);
+        sched.run();
+    }
+}
+
+/// Test tasks will abort on failure instead of unwinding
+pub fn spawntask(f: ~fn()) {
+    use super::sched::*;
+
+    let mut sched = local_sched::take();
+    let task = ~Task::with_local(&mut sched.stack_pool,
+                                 LocalServices::without_unwinding(),
+                                 f);
+    do sched.switch_running_tasks_and_then(task) |task| {
+        let task = Cell(task);
+        let sched = local_sched::take();
+        sched.schedule_new_task(task.take());
+    }
+}
+
+/// Create a new task and run it right now. Aborts on failure
+pub fn spawntask_immediately(f: ~fn()) {
+    use super::sched::*;
+
+    let mut sched = local_sched::take();
+    let task = ~Task::with_local(&mut sched.stack_pool,
+                                 LocalServices::without_unwinding(),
+                                 f);
+    do sched.switch_running_tasks_and_then(task) |task| {
+        let task = Cell(task);
+        do local_sched::borrow |sched| {
+            sched.task_queue.push_front(task.take());
+        }
+    }
+}
+
+/// Spawn a task and wait for it to finish, returning whether it completed successfully or failed
+pub fn spawntask_try(f: ~fn()) -> Result<(), ()> {
+    use cell::Cell;
+    use super::sched::*;
+    use task;
+    use unstable::finally::Finally;
+
+    // Our status variables will be filled in from the scheduler context
+    let mut failed = false;
+    let failed_ptr: *mut bool = &mut failed;
+
+    // Switch to the scheduler
+    let f = Cell(Cell(f));
+    let mut sched = local_sched::take();
+    do sched.deschedule_running_task_and_then() |old_task| {
+        let old_task = Cell(old_task);
+        let f = f.take();
+        let mut sched = local_sched::take();
+        let new_task = ~do Task::new(&mut sched.stack_pool) {
+            do (|| {
+                (f.take())()
+            }).finally {
+                // Check for failure then resume the parent task
+                unsafe { *failed_ptr = task::failing(); }
+                let sched = local_sched::take();
+                do sched.switch_running_tasks_and_then(old_task.take()) |new_task| {
+                    let new_task = Cell(new_task);
+                    do local_sched::borrow |sched| {
+                        sched.task_queue.push_front(new_task.take());
+                    }
+                }
+            }
+        };
+
+        sched.resume_task_immediately(new_task);
+    }
+
+    if !failed { Ok(()) } else { Err(()) }
+}
+
+/// Get a port number, starting at 9600, for use in tests
+pub fn next_test_port() -> u16 {
+    unsafe {
+        return rust_dbg_next_port() as u16;
+    }
+    extern {
+        fn rust_dbg_next_port() -> ::libc::uintptr_t;
+    }
+}
+
+/// Get a unique localhost:port pair starting at 9600
+pub fn next_test_ip4() -> IpAddr {
+    Ipv4(127, 0, 0, 1, next_test_port())
+}
diff --git a/src/libcore/rt/uv/mod.rs b/src/libcore/rt/uv/mod.rs
index cb7925abdcd..013a28abf28 100644
--- a/src/libcore/rt/uv/mod.rs
+++ b/src/libcore/rt/uv/mod.rs
@@ -301,7 +301,8 @@ struct WatcherData {
     write_cb: Option<ConnectionCallback>,
     connect_cb: Option<ConnectionCallback>,
     close_cb: Option<NullCallback>,
-    alloc_cb: Option<AllocCallback>
+    alloc_cb: Option<AllocCallback>,
+    buf: Option<Buf>
 }
 
 pub fn install_watcher_data<H, W: Watcher + NativeHandle<*H>>(watcher: &mut W) {
@@ -311,7 +312,8 @@ pub fn install_watcher_data<H, W: Watcher + NativeHandle<*H>>(watcher: &mut W) {
             write_cb: None,
             connect_cb: None,
             close_cb: None,
-            alloc_cb: None
+            alloc_cb: None,
+            buf: None
         };
         let data = transmute::<~WatcherData, *c_void>(data);
         uvll::set_data_for_uv_handle(watcher.native_handle(), data);
diff --git a/src/libcore/rt/uv/net.rs b/src/libcore/rt/uv/net.rs
index bcfe8b2cfdf..04b9008b067 100644
--- a/src/libcore/rt/uv/net.rs
+++ b/src/libcore/rt/uv/net.rs
@@ -19,12 +19,10 @@ use super::{Loop, Watcher, Request, UvError, Buf, Callback, NativeHandle, NullCa
             vec_to_uv_buf, vec_from_uv_buf};
 use super::super::io::net::ip::{IpAddr, Ipv4, Ipv6};
 
-#[cfg(test)]
-use unstable::run_in_bare_thread;
-#[cfg(test)]
-use super::super::thread::Thread;
-#[cfg(test)]
-use cell::Cell;
+#[cfg(test)] use cell::Cell;
+#[cfg(test)] use unstable::run_in_bare_thread;
+#[cfg(test)] use super::super::thread::Thread;
+#[cfg(test)] use super::super::test::*;
 
 fn ip4_as_uv_ip4(addr: IpAddr, f: &fn(*sockaddr_in)) {
     match addr {
@@ -109,21 +107,25 @@ pub impl StreamWatcher {
 
         let req = WriteRequest::new();
         let buf = vec_to_uv_buf(msg);
-        // XXX: Allocation
-        let bufs = ~[buf];
+        assert!(data.buf.is_none());
+        data.buf = Some(buf);
+        let bufs = [buf];
         unsafe {
             assert!(0 == uvll::write(req.native_handle(),
                                           self.native_handle(),
-                                          &bufs, write_cb));
+                                          bufs, write_cb));
         }
-        // XXX: Freeing immediately after write. Is this ok?
-        let _v = vec_from_uv_buf(buf);
 
         extern fn write_cb(req: *uvll::uv_write_t, status: c_int) {
             let write_request: WriteRequest = NativeHandle::from_native_handle(req);
             let mut stream_watcher = write_request.stream();
             write_request.delete();
-            let cb = get_watcher_data(&mut stream_watcher).write_cb.swap_unwrap();
+            let cb = {
+                let data = get_watcher_data(&mut stream_watcher);
+                let _vec = vec_from_uv_buf(data.buf.swap_unwrap());
+                let cb = data.write_cb.swap_unwrap();
+                cb
+            };
             let status = status_to_maybe_uv_error(stream_watcher.native_handle(), status);
             cb(stream_watcher, status);
         }
@@ -361,7 +363,7 @@ fn connect_close() {
         let mut loop_ = Loop::new();
         let mut tcp_watcher = { TcpWatcher::new(&mut loop_) };
         // Connect to a port where nobody is listening
-        let addr = Ipv4(127, 0, 0, 1, 2923);
+        let addr = next_test_ip4();
         do tcp_watcher.connect(addr) |stream_watcher, status| {
             rtdebug!("tcp_watcher.connect!");
             assert!(status.is_some());
@@ -374,46 +376,12 @@ fn connect_close() {
 }
 
 #[test]
-#[ignore(reason = "need a server to connect to")]
-fn connect_read() {
-    do run_in_bare_thread() {
-        let mut loop_ = Loop::new();
-        let mut tcp_watcher = { TcpWatcher::new(&mut loop_) };
-        let addr = Ipv4(127, 0, 0, 1, 2924);
-        do tcp_watcher.connect(addr) |stream_watcher, status| {
-            let mut stream_watcher = stream_watcher;
-            rtdebug!("tcp_watcher.connect!");
-            assert!(status.is_none());
-            let alloc: AllocCallback = |size| {
-                vec_to_uv_buf(vec::from_elem(size, 0))
-            };
-            do stream_watcher.read_start(alloc)
-                |stream_watcher, _nread, buf, status| {
-
-                let buf = vec_from_uv_buf(buf);
-                rtdebug!("read cb!");
-                if status.is_none() {
-                    let _bytes = buf.unwrap();
-                    rtdebug!("%s", bytes.slice(0, nread as uint).to_str());
-                } else {
-                    rtdebug!("status after read: %s", status.get().to_str());
-                    rtdebug!("closing");
-                    stream_watcher.close(||());
-                }
-            }
-        }
-        loop_.run();
-        loop_.close();
-    }
-}
-
-#[test]
 fn listen() {
     do run_in_bare_thread() {
         static MAX: int = 10;
         let mut loop_ = Loop::new();
         let mut server_tcp_watcher = { TcpWatcher::new(&mut loop_) };
-        let addr = Ipv4(127, 0, 0, 1, 2925);
+        let addr = next_test_ip4();
         server_tcp_watcher.bind(addr);
         let loop_ = loop_;
         rtdebug!("listening");
diff --git a/src/libcore/rt/uvio.rs b/src/libcore/rt/uvio.rs
index fba91dd7d8a..ab8aea2b63c 100644
--- a/src/libcore/rt/uvio.rs
+++ b/src/libcore/rt/uvio.rs
@@ -19,10 +19,9 @@ use cell::{Cell, empty_cell};
 use cast::transmute;
 use super::sched::{Scheduler, local_sched};
 
-#[cfg(test)] use super::io::net::ip::Ipv4;
-#[cfg(test)] use super::sched::Task;
-#[cfg(test)] use unstable::run_in_bare_thread;
 #[cfg(test)] use uint;
+#[cfg(test)] use unstable::run_in_bare_thread;
+#[cfg(test)] use super::test::*;
 
 pub struct UvEventLoop {
     uvio: UvIoFactory
@@ -319,38 +318,22 @@ impl Stream for UvStream {
 }
 
 #[test]
-#[ignore(reason = "ffi struct issues")]
 fn test_simple_io_no_connect() {
-    do run_in_bare_thread {
-        let mut sched = ~UvEventLoop::new_scheduler();
-        let task = ~do Task::new(&mut sched.stack_pool) {
-            let io = unsafe { local_sched::unsafe_borrow_io() };
-            let addr = Ipv4(127, 0, 0, 1, 2926);
-            let maybe_chan = io.connect(addr);
-            assert!(maybe_chan.is_none());
-        };
-        sched.task_queue.push_back(task);
-        sched.run();
+    do run_in_newsched_task {
+        let io = unsafe { local_sched::unsafe_borrow_io() };
+        let addr = next_test_ip4();
+        let maybe_chan = io.connect(addr);
+        assert!(maybe_chan.is_none());
     }
 }
 
 #[test]
-#[ignore(reason = "ffi struct issues")]
 fn test_simple_tcp_server_and_client() {
-    do run_in_bare_thread {
-        let mut sched = ~UvEventLoop::new_scheduler();
-        let addr = Ipv4(127, 0, 0, 1, 2929);
-
-        let client_task = ~do Task::new(&mut sched.stack_pool) {
-            unsafe {
-                let io = local_sched::unsafe_borrow_io();
-                let mut stream = io.connect(addr).unwrap();
-                stream.write([0, 1, 2, 3, 4, 5, 6, 7]);
-                stream.close();
-            }
-        };
+    do run_in_newsched_task {
+        let addr = next_test_ip4();
 
-        let server_task = ~do Task::new(&mut sched.stack_pool) {
+        // Start the server first so it's listening when we connect
+        do spawntask_immediately {
             unsafe {
                 let io = local_sched::unsafe_borrow_io();
                 let mut listener = io.bind(addr).unwrap();
@@ -365,32 +348,25 @@ fn test_simple_tcp_server_and_client() {
                 stream.close();
                 listener.close();
             }
-        };
+        }
 
-        // Start the server first so it listens before the client connects
-        sched.task_queue.push_back(server_task);
-        sched.task_queue.push_back(client_task);
-        sched.run();
+        do spawntask_immediately {
+            unsafe {
+                let io = local_sched::unsafe_borrow_io();
+                let mut stream = io.connect(addr).unwrap();
+                stream.write([0, 1, 2, 3, 4, 5, 6, 7]);
+                stream.close();
+            }
+        }
     }
 }
 
 #[test] #[ignore(reason = "busted")]
 fn test_read_and_block() {
-    do run_in_bare_thread {
-        let mut sched = ~UvEventLoop::new_scheduler();
-        let addr = Ipv4(127, 0, 0, 1, 2930);
+    do run_in_newsched_task {
+        let addr = next_test_ip4();
 
-        let client_task = ~do Task::new(&mut sched.stack_pool) {
-            let io = unsafe { local_sched::unsafe_borrow_io() };
-            let mut stream = io.connect(addr).unwrap();
-            stream.write([0, 1, 2, 3, 4, 5, 6, 7]);
-            stream.write([0, 1, 2, 3, 4, 5, 6, 7]);
-            stream.write([0, 1, 2, 3, 4, 5, 6, 7]);
-            stream.write([0, 1, 2, 3, 4, 5, 6, 7]);
-            stream.close();
-        };
-
-        let server_task = ~do Task::new(&mut sched.stack_pool) {
+        do spawntask_immediately {
             let io = unsafe { local_sched::unsafe_borrow_io() };
             let mut listener = io.bind(addr).unwrap();
             let mut stream = listener.listen().unwrap();
@@ -426,36 +402,58 @@ fn test_read_and_block() {
 
             stream.close();
             listener.close();
-        };
+        }
+
+        do spawntask_immediately {
+            let io = unsafe { local_sched::unsafe_borrow_io() };
+            let mut stream = io.connect(addr).unwrap();
+            stream.write([0, 1, 2, 3, 4, 5, 6, 7]);
+            stream.write([0, 1, 2, 3, 4, 5, 6, 7]);
+            stream.write([0, 1, 2, 3, 4, 5, 6, 7]);
+            stream.write([0, 1, 2, 3, 4, 5, 6, 7]);
+            stream.close();
+        }
 
-        // Start the server first so it listens before the client connects
-        sched.task_queue.push_back(server_task);
-        sched.task_queue.push_back(client_task);
-        sched.run();
     }
 }
 
-#[test] #[ignore(reason = "needs server")]
+#[test]
 fn test_read_read_read() {
-    do run_in_bare_thread {
-        let mut sched = ~UvEventLoop::new_scheduler();
-        let addr = Ipv4(127, 0, 0, 1, 2931);
+    do run_in_newsched_task {
+        let addr = next_test_ip4();
+        static MAX: uint = 500000;
 
-        let client_task = ~do Task::new(&mut sched.stack_pool) {
+        do spawntask_immediately {
+            unsafe {
+                let io = local_sched::unsafe_borrow_io();
+                let mut listener = io.bind(addr).unwrap();
+                let mut stream = listener.listen().unwrap();
+                let mut buf = [1, .. 2048];
+                let mut total_bytes_written = 0;
+                while total_bytes_written < MAX {
+                    stream.write(buf);
+                    total_bytes_written += buf.len();
+                }
+                stream.close();
+                listener.close();
+            }
+        }
+
+        do spawntask_immediately {
             let io = unsafe { local_sched::unsafe_borrow_io() };
             let mut stream = io.connect(addr).unwrap();
             let mut buf = [0, .. 2048];
             let mut total_bytes_read = 0;
-            while total_bytes_read < 500000000 {
+            while total_bytes_read < MAX {
                 let nread = stream.read(buf).unwrap();
                 rtdebug!("read %u bytes", nread as uint);
                 total_bytes_read += nread;
+                for uint::range(0, nread) |i| {
+                    assert!(buf[i] == 1);
+                }
             }
-            rtdebug_!("read %u bytes total", total_bytes_read as uint);
+            rtdebug!("read %u bytes total", total_bytes_read as uint);
             stream.close();
-        };
-
-        sched.task_queue.push_back(client_task);
-        sched.run();
+        }
     }
 }
diff --git a/src/libcore/rt/uvll.rs b/src/libcore/rt/uvll.rs
index c9a696fcd15..3eb7f8006b9 100644
--- a/src/libcore/rt/uvll.rs
+++ b/src/libcore/rt/uvll.rs
@@ -219,9 +219,9 @@ pub unsafe fn accept(server: *c_void, client: *c_void) -> c_int {
     return rust_uv_accept(server as *c_void, client as *c_void);
 }
 
-pub unsafe fn write<T>(req: *uv_write_t, stream: *T, buf_in: *~[uv_buf_t], cb: *u8) -> c_int {
-    let buf_ptr = vec::raw::to_ptr(*buf_in);
-    let buf_cnt = vec::len(*buf_in) as i32;
+pub unsafe fn write<T>(req: *uv_write_t, stream: *T, buf_in: &[uv_buf_t], cb: *u8) -> c_int {
+    let buf_ptr = vec::raw::to_ptr(buf_in);
+    let buf_cnt = vec::len(buf_in) as i32;
     return rust_uv_write(req as *c_void, stream as *c_void, buf_ptr, buf_cnt, cb);
 }
 pub unsafe fn read_start(stream: *uv_stream_t, on_alloc: *u8, on_read: *u8) -> c_int {
diff --git a/src/libcore/run.rs b/src/libcore/run.rs
index 37401788ca2..7e73b3a3f80 100644
--- a/src/libcore/run.rs
+++ b/src/libcore/run.rs
@@ -22,31 +22,6 @@ use str;
 use task;
 use vec;
 
-pub mod rustrt {
-    use libc::{c_int, c_void};
-    use libc;
-    use run;
-
-    #[abi = "cdecl"]
-    pub extern {
-        unsafe fn rust_run_program(argv: **libc::c_char,
-                                   envp: *c_void,
-                                   dir: *libc::c_char,
-                                   in_fd: c_int,
-                                   out_fd: c_int,
-                                   err_fd: c_int) -> run::RunProgramResult;
-        unsafe fn rust_process_wait(pid: c_int) -> c_int;
-    }
-}
-
-pub struct RunProgramResult {
-    // the process id of the program, or -1 if in case of errors
-    pid: pid_t,
-    // a handle to the process - on unix this will always be NULL, but on windows it will be a
-    // HANDLE to the process, which will prevent the pid being re-used until the handle is closed.
-    handle: *(),
-}
-
 /// A value representing a child process
 pub struct Program {
     priv pid: pid_t,
@@ -191,21 +166,262 @@ pub fn spawn_process(prog: &str, args: &[~str],
     return res.pid;
 }
 
+struct RunProgramResult {
+    // the process id of the program (this should never be negative)
+    pid: pid_t,
+    // a handle to the process - on unix this will always be NULL, but on windows it will be a
+    // HANDLE to the process, which will prevent the pid being re-used until the handle is closed.
+    handle: *(),
+}
+
+#[cfg(windows)]
 fn spawn_process_internal(prog: &str, args: &[~str],
                           env: &Option<~[(~str,~str)]>,
                           dir: &Option<~str>,
                           in_fd: c_int, out_fd: c_int, err_fd: c_int) -> RunProgramResult {
+
+    use libc::types::os::arch::extra::{DWORD, HANDLE, STARTUPINFO};
+    use libc::consts::os::extra::{
+        TRUE, FALSE,
+        STARTF_USESTDHANDLES,
+        INVALID_HANDLE_VALUE,
+        DUPLICATE_SAME_ACCESS
+    };
+    use libc::funcs::extra::kernel32::{
+        GetCurrentProcess,
+        DuplicateHandle,
+        CloseHandle,
+        CreateProcessA
+    };
+    use libc::funcs::extra::msvcrt::get_osfhandle;
+
     unsafe {
-        do with_argv(prog, args) |argv| {
-            do with_envp(env) |envp| {
-                do with_dirp(dir) |dirp| {
-                    rustrt::rust_run_program(argv, envp, dirp, in_fd, out_fd, err_fd)
+
+        let mut si = zeroed_startupinfo();
+        si.cb = sys::size_of::<STARTUPINFO>() as DWORD;
+        si.dwFlags = STARTF_USESTDHANDLES;
+
+        let cur_proc = GetCurrentProcess();
+
+        let orig_std_in = get_osfhandle(if in_fd > 0 { in_fd } else { 0 }) as HANDLE;
+        if orig_std_in == INVALID_HANDLE_VALUE as HANDLE {
+            fail!(fmt!("failure in get_osfhandle: %s", os::last_os_error()));
+        }
+        if DuplicateHandle(cur_proc, orig_std_in, cur_proc, &mut si.hStdInput,
+                           0, TRUE, DUPLICATE_SAME_ACCESS) == FALSE {
+            fail!(fmt!("failure in DuplicateHandle: %s", os::last_os_error()));
+        }
+
+        let orig_std_out = get_osfhandle(if out_fd > 0 { out_fd } else { 1 }) as HANDLE;
+        if orig_std_out == INVALID_HANDLE_VALUE as HANDLE {
+            fail!(fmt!("failure in get_osfhandle: %s", os::last_os_error()));
+        }
+        if DuplicateHandle(cur_proc, orig_std_out, cur_proc, &mut si.hStdOutput,
+                           0, TRUE, DUPLICATE_SAME_ACCESS) == FALSE {
+            fail!(fmt!("failure in DuplicateHandle: %s", os::last_os_error()));
+        }
+
+        let orig_std_err = get_osfhandle(if err_fd > 0 { err_fd } else { 2 }) as HANDLE;
+        if orig_std_err as HANDLE == INVALID_HANDLE_VALUE as HANDLE {
+            fail!(fmt!("failure in get_osfhandle: %s", os::last_os_error()));
+        }
+        if DuplicateHandle(cur_proc, orig_std_err, cur_proc, &mut si.hStdError,
+                           0, TRUE, DUPLICATE_SAME_ACCESS) == FALSE {
+            fail!(fmt!("failure in DuplicateHandle: %s", os::last_os_error()));
+        }
+
+        let cmd = make_command_line(prog, args);
+        let mut pi = zeroed_process_information();
+        let mut create_err = None;
+
+        do with_envp(env) |envp| {
+            do with_dirp(dir) |dirp| {
+                do str::as_c_str(cmd) |cmdp| {
+                    let created = CreateProcessA(ptr::null(), cast::transmute(cmdp),
+                                                 ptr::mut_null(), ptr::mut_null(), TRUE,
+                                                 0, envp, dirp, &mut si, &mut pi);
+                    if created == FALSE {
+                        create_err = Some(os::last_os_error());
+                    }
                 }
             }
         }
+
+        CloseHandle(si.hStdInput);
+        CloseHandle(si.hStdOutput);
+        CloseHandle(si.hStdError);
+
+        for create_err.each |msg| {
+            fail!(fmt!("failure in CreateProcess: %s", *msg));
+        }
+
+        // We close the thread handle because we don't care about keeping the thread id valid,
+        // and we aren't keeping the thread handle around to be able to close it later. We don't
+        // close the process handle however because we want the process id to stay valid at least
+        // until the calling code closes the process handle.
+        CloseHandle(pi.hThread);
+
+        RunProgramResult {
+            pid: pi.dwProcessId as pid_t,
+            handle: pi.hProcess as *()
+        }
+    }
+}
+
+#[cfg(windows)]
+fn zeroed_startupinfo() -> libc::types::os::arch::extra::STARTUPINFO {
+    libc::types::os::arch::extra::STARTUPINFO {
+        cb: 0,
+        lpReserved: ptr::mut_null(),
+        lpDesktop: ptr::mut_null(),
+        lpTitle: ptr::mut_null(),
+        dwX: 0,
+        dwY: 0,
+        dwXSize: 0,
+        dwYSize: 0,
+        dwXCountChars: 0,
+        dwYCountCharts: 0,
+        dwFillAttribute: 0,
+        dwFlags: 0,
+        wShowWindow: 0,
+        cbReserved2: 0,
+        lpReserved2: ptr::mut_null(),
+        hStdInput: ptr::mut_null(),
+        hStdOutput: ptr::mut_null(),
+        hStdError: ptr::mut_null()
     }
 }
 
+#[cfg(windows)]
+fn zeroed_process_information() -> libc::types::os::arch::extra::PROCESS_INFORMATION {
+    libc::types::os::arch::extra::PROCESS_INFORMATION {
+        hProcess: ptr::mut_null(),
+        hThread: ptr::mut_null(),
+        dwProcessId: 0,
+        dwThreadId: 0
+    }
+}
+
+// FIXME: this is only pub so it can be tested (see issue #4536)
+#[cfg(windows)]
+pub fn make_command_line(prog: &str, args: &[~str]) -> ~str {
+
+    let mut cmd = ~"";
+    append_arg(&mut cmd, prog);
+    for args.each |arg| {
+        cmd.push_char(' ');
+        append_arg(&mut cmd, *arg);
+    }
+    return cmd;
+
+    fn append_arg(cmd: &mut ~str, arg: &str) {
+        let quote = arg.any(|c| c == ' ' || c == '\t');
+        if quote {
+            cmd.push_char('"');
+        }
+        for uint::range(0, arg.len()) |i| {
+            append_char_at(cmd, arg, i);
+        }
+        if quote {
+            cmd.push_char('"');
+        }
+    }
+
+    fn append_char_at(cmd: &mut ~str, arg: &str, i: uint) {
+        match arg[i] as char {
+            '"' => {
+                // Escape quotes.
+                cmd.push_str("\\\"");
+            }
+            '\\' => {
+                if backslash_run_ends_in_quote(arg, i) {
+                    // Double all backslashes that are in runs before quotes.
+                    cmd.push_str("\\\\");
+                } else {
+                    // Pass other backslashes through unescaped.
+                    cmd.push_char('\\');
+                }
+            }
+            c => {
+                cmd.push_char(c);
+            }
+        }
+    }
+
+    fn backslash_run_ends_in_quote(s: &str, mut i: uint) -> bool {
+        while i < s.len() && s[i] as char == '\\' {
+            i += 1;
+        }
+        return i < s.len() && s[i] as char == '"';
+    }
+}
+
+#[cfg(unix)]
+fn spawn_process_internal(prog: &str, args: &[~str],
+                          env: &Option<~[(~str,~str)]>,
+                          dir: &Option<~str>,
+                          in_fd: c_int, out_fd: c_int, err_fd: c_int) -> RunProgramResult {
+
+    use libc::funcs::posix88::unistd::{fork, dup2, close, chdir, execvp};
+    use libc::funcs::bsd44::getdtablesize;
+
+    mod rustrt {
+        use libc::c_void;
+
+        #[abi = "cdecl"]
+        pub extern {
+            unsafe fn rust_unset_sigprocmask();
+            unsafe fn rust_set_environ(envp: *c_void);
+        }
+    }
+
+    unsafe {
+
+        let pid = fork();
+        if pid < 0 {
+            fail!(fmt!("failure in fork: %s", os::last_os_error()));
+        } else if pid > 0 {
+            return RunProgramResult {pid: pid, handle: ptr::null()};
+        }
+
+        rustrt::rust_unset_sigprocmask();
+
+        if in_fd > 0 && dup2(in_fd, 0) == -1 {
+            fail!(fmt!("failure in dup2(in_fd, 0): %s", os::last_os_error()));
+        }
+        if out_fd > 0 && dup2(out_fd, 1) == -1 {
+            fail!(fmt!("failure in dup2(out_fd, 1): %s", os::last_os_error()));
+        }
+        if err_fd > 0 && dup2(err_fd, 2) == -1 {
+            fail!(fmt!("failure in dup3(err_fd, 2): %s", os::last_os_error()));
+        }
+        // close all other fds
+        for int::range_rev(getdtablesize() as int - 1, 2) |fd| {
+            close(fd as c_int);
+        }
+
+        for dir.each |dir| {
+            do str::as_c_str(*dir) |dirp| {
+                if chdir(dirp) == -1 {
+                    fail!(fmt!("failure in chdir: %s", os::last_os_error()));
+                }
+            }
+        }
+
+        do with_envp(env) |envp| {
+            if !envp.is_null() {
+                rustrt::rust_set_environ(envp);
+            }
+            do with_argv(prog, args) |argv| {
+                execvp(*argv, argv);
+                // execvp only returns if an error occurred
+                fail!(fmt!("failure in execvp: %s", os::last_os_error()));
+            }
+        }
+    }
+}
+
+#[cfg(unix)]
 fn with_argv<T>(prog: &str, args: &[~str],
                 cb: &fn(**libc::c_char) -> T) -> T {
     let mut argptrs = str::as_c_str(prog, |b| ~[b]);
@@ -246,7 +462,7 @@ fn with_envp<T>(env: &Option<~[(~str,~str)]>,
 
 #[cfg(windows)]
 fn with_envp<T>(env: &Option<~[(~str,~str)]>,
-                cb: &fn(*c_void) -> T) -> T {
+                cb: &fn(*mut c_void) -> T) -> T {
     // On win32 we pass an "environment block" which is not a char**, but
     // rather a concatenation of null-terminated k=v\0 sequences, with a final
     // \0 to terminate.
@@ -264,11 +480,12 @@ fn with_envp<T>(env: &Option<~[(~str,~str)]>,
             blk += ~[0_u8];
             vec::as_imm_buf(blk, |p, _len| cb(::cast::transmute(p)))
           }
-          _ => cb(ptr::null())
+          _ => cb(ptr::mut_null())
         }
     }
 }
 
+#[cfg(windows)]
 fn with_dirp<T>(d: &Option<~str>,
                 cb: &fn(*libc::c_char) -> T) -> T {
     match *d {
@@ -312,8 +529,6 @@ priv fn free_handle(_handle: *()) {
 pub fn run_program(prog: &str, args: &[~str]) -> int {
     let res = spawn_process_internal(prog, args, &None, &None,
                                      0i32, 0i32, 0i32);
-    if res.pid == -1 as pid_t { fail!(); }
-
     let code = waitpid(res.pid);
     free_handle(res.handle);
     return code;
@@ -345,7 +560,6 @@ pub fn start_program(prog: &str, args: &[~str]) -> Program {
                                pipe_err.out);
 
     unsafe {
-        if res.pid == -1 as pid_t { fail!(); }
         libc::close(pipe_input.in);
         libc::close(pipe_output.out);
         libc::close(pipe_err.out);
@@ -398,13 +612,6 @@ pub fn program_output(prog: &str, args: &[~str]) -> ProgramOutput {
     os::close(pipe_in.in);
     os::close(pipe_out.out);
     os::close(pipe_err.out);
-    if res.pid == -1i32 {
-        os::close(pipe_in.out);
-        os::close(pipe_out.in);
-        os::close(pipe_err.in);
-        fail!();
-    }
-
     os::close(pipe_in.out);
 
     // Spawn two entire schedulers to read both stdout and sterr
@@ -485,11 +692,46 @@ pub fn waitpid(pid: pid_t) -> int {
 
     #[cfg(windows)]
     fn waitpid_os(pid: pid_t) -> int {
-        let status = unsafe { rustrt::rust_process_wait(pid) };
-        if status < 0 {
-            fail!(fmt!("failure in rust_process_wait: %s", os::last_os_error()));
+
+        use libc::types::os::arch::extra::DWORD;
+        use libc::consts::os::extra::{
+            SYNCHRONIZE,
+            PROCESS_QUERY_INFORMATION,
+            FALSE,
+            STILL_ACTIVE,
+            INFINITE,
+            WAIT_FAILED
+        };
+        use libc::funcs::extra::kernel32::{
+            OpenProcess,
+            GetExitCodeProcess,
+            CloseHandle,
+            WaitForSingleObject
+        };
+
+        unsafe {
+
+            let proc = OpenProcess(SYNCHRONIZE | PROCESS_QUERY_INFORMATION, FALSE, pid as DWORD);
+            if proc.is_null() {
+                fail!(fmt!("failure in OpenProcess: %s", os::last_os_error()));
+            }
+
+            loop {
+                let mut status = 0;
+                if GetExitCodeProcess(proc, &mut status) == FALSE {
+                    CloseHandle(proc);
+                    fail!(fmt!("failure in GetExitCodeProcess: %s", os::last_os_error()));
+                }
+                if status != STILL_ACTIVE {
+                    CloseHandle(proc);
+                    return status as int;
+                }
+                if WaitForSingleObject(proc, INFINITE) == WAIT_FAILED {
+                    CloseHandle(proc);
+                    fail!(fmt!("failure in WaitForSingleObject: %s", os::last_os_error()));
+                }
+            }
         }
-        return status as int;
     }
 
     #[cfg(unix)]
@@ -539,10 +781,30 @@ mod tests {
     use libc;
     use option::None;
     use os;
-    use path::Path;
     use run::{readclose, writeclose};
     use run;
 
+    #[test]
+    #[cfg(windows)]
+    fn test_make_command_line() {
+        assert_eq!(
+            run::make_command_line("prog", [~"aaa", ~"bbb", ~"ccc"]),
+            ~"prog aaa bbb ccc"
+        );
+        assert_eq!(
+            run::make_command_line("C:\\Program Files\\blah\\blah.exe", [~"aaa"]),
+            ~"\"C:\\Program Files\\blah\\blah.exe\" aaa"
+        );
+        assert_eq!(
+            run::make_command_line("C:\\Program Files\\test", [~"aa\"bb"]),
+            ~"\"C:\\Program Files\\test\" aa\\\"bb"
+        );
+        assert_eq!(
+            run::make_command_line("echo", [~"a b c"]),
+            ~"echo \"a b c\""
+        );
+    }
+
     // Regression test for memory leaks
     #[test]
     fn test_leaks() {
@@ -607,43 +869,60 @@ mod tests {
         p.destroy(); // ...and nor should this (and nor should the destructor)
     }
 
-    #[cfg(unix)] // there is no way to sleep on windows from inside libcore...
     fn test_destroy_actually_kills(force: bool) {
-        let path = Path(fmt!("test/core-run-test-destroy-actually-kills-%?.tmp", force));
 
-        os::remove_file(&path);
+        #[cfg(unix)]
+        static BLOCK_COMMAND: &'static str = "cat";
 
-        let cmd = fmt!("sleep 5 && echo MurderDeathKill > %s", path.to_str());
-        let mut p = run::start_program("sh", [~"-c", cmd]);
+        #[cfg(windows)]
+        static BLOCK_COMMAND: &'static str = "cmd";
 
-        p.destroy(); // destroy the program before it has a chance to echo its message
+        #[cfg(unix)]
+        fn process_exists(pid: libc::pid_t) -> bool {
+            run::program_output("ps", [~"-p", pid.to_str()]).out.contains(pid.to_str())
+        }
 
-        unsafe {
-            // wait to ensure the program is really destroyed and not just waiting itself
-            libc::sleep(10);
+        #[cfg(windows)]
+        fn process_exists(pid: libc::pid_t) -> bool {
+
+            use libc::types::os::arch::extra::DWORD;
+            use libc::funcs::extra::kernel32::{CloseHandle, GetExitCodeProcess, OpenProcess};
+            use libc::consts::os::extra::{FALSE, PROCESS_QUERY_INFORMATION, STILL_ACTIVE };
+
+            unsafe {
+                let proc = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid as DWORD);
+                if proc.is_null() {
+                    return false;
+                }
+                // proc will be non-null if the process is alive, or if it died recently
+                let mut status = 0;
+                GetExitCodeProcess(proc, &mut status);
+                CloseHandle(proc);
+                return status == STILL_ACTIVE;
+            }
         }
 
-        // the program should not have had chance to echo its message
-        assert!(!path.exists());
+        // this program will stay alive indefinitely trying to read from stdin
+        let mut p = run::start_program(BLOCK_COMMAND, []);
+
+        assert!(process_exists(p.get_id()));
+
+        if force {
+            p.force_destroy();
+        } else {
+            p.destroy();
+        }
+
+        assert!(!process_exists(p.get_id()));
     }
 
     #[test]
-    #[cfg(unix)]
     fn test_unforced_destroy_actually_kills() {
         test_destroy_actually_kills(false);
     }
 
     #[test]
-    #[cfg(unix)]
     fn test_forced_destroy_actually_kills() {
         test_destroy_actually_kills(true);
     }
 }
-
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
diff --git a/src/libcore/stackwalk.rs b/src/libcore/stackwalk.rs
index ebf36e4e09a..987d4064ab9 100644
--- a/src/libcore/stackwalk.rs
+++ b/src/libcore/stackwalk.rs
@@ -93,10 +93,6 @@ pub mod rustrt {
 pub mod rusti {
     #[abi = "rust-intrinsic"]
     pub extern "rust-intrinsic" {
-        #[cfg(stage0)]
-        pub fn frame_address(f: &once fn(x: *u8));
-        #[cfg(not(stage0))]
         pub fn frame_address(+f: &once fn(x: *u8));
     }
 }
-
diff --git a/src/libcore/str.rs b/src/libcore/str.rs
index f4430ca669f..a41c99b266b 100644
--- a/src/libcore/str.rs
+++ b/src/libcore/str.rs
@@ -77,6 +77,7 @@ pub fn from_bytes_slice<'a>(vector: &'a [u8]) -> &'a str {
 }
 
 /// Copy a slice into a new unique str
+#[inline(always)]
 pub fn from_slice(s: &str) -> ~str {
     unsafe { raw::slice_bytes_owned(s, 0, len(s)) }
 }
@@ -240,38 +241,132 @@ pub fn append(lhs: ~str, rhs: &str) -> ~str {
 
 /// Concatenate a vector of strings
 pub fn concat(v: &[~str]) -> ~str {
-    let mut s: ~str = ~"";
-    for vec::each(v) |ss| {
-        push_str(&mut s, *ss);
+    if v.is_empty() { return ~""; }
+
+    let mut len = 0;
+    for v.each |ss| {
+        len += ss.len();
+    }
+    let mut s = ~"";
+
+    reserve(&mut s, len);
+
+    unsafe {
+        do as_buf(s) |buf, _len| {
+            let mut buf = ::cast::transmute_mut_unsafe(buf);
+            for v.each |ss| {
+                do as_buf(*ss) |ssbuf, sslen| {
+                    let sslen = sslen - 1;
+                    ptr::copy_memory(buf, ssbuf, sslen);
+                    buf = buf.offset(sslen);
+                }
+            }
+        }
+        raw::set_len(&mut s, len);
     }
     s
 }
 
 /// Concatenate a vector of strings, placing a given separator between each
 pub fn connect(v: &[~str], sep: &str) -> ~str {
+    if v.is_empty() { return ~""; }
+
+    // concat is faster
+    if sep.is_empty() { return concat(v); }
+
+    // this is wrong without the guarantee that v is non-empty
+    let mut len = sep.len() * (v.len() - 1);
+    for v.each |ss| {
+        len += ss.len();
+    }
     let mut s = ~"", first = true;
-    for vec::each(v) |ss| {
-        if first { first = false; } else { push_str(&mut s, sep); }
-        push_str(&mut s, *ss);
+
+    reserve(&mut s, len);
+
+    unsafe {
+        do as_buf(s) |buf, _len| {
+            do as_buf(sep) |sepbuf, seplen| {
+                let seplen = seplen - 1;
+                let mut buf = ::cast::transmute_mut_unsafe(buf);
+                for v.each |ss| {
+                    do as_buf(*ss) |ssbuf, sslen| {
+                        let sslen = sslen - 1;
+                        if first {
+                            first = false;
+                        } else {
+                            ptr::copy_memory(buf, sepbuf, seplen);
+                            buf = buf.offset(seplen);
+                        }
+                        ptr::copy_memory(buf, ssbuf, sslen);
+                        buf = buf.offset(sslen);
+                    }
+                }
+            }
+        }
+        raw::set_len(&mut s, len);
     }
     s
 }
 
 /// Concatenate a vector of strings, placing a given separator between each
 pub fn connect_slices(v: &[&str], sep: &str) -> ~str {
+    if v.is_empty() { return ~""; }
+
+    // this is wrong without the guarantee that v is non-empty
+    let mut len = sep.len() * (v.len() - 1);
+    for v.each |ss| {
+        len += ss.len();
+    }
     let mut s = ~"", first = true;
-    for vec::each(v) |ss| {
-        if first { first = false; } else { push_str(&mut s, sep); }
-        push_str(&mut s, *ss);
+
+    reserve(&mut s, len);
+
+    unsafe {
+        do as_buf(s) |buf, _len| {
+            do as_buf(sep) |sepbuf, seplen| {
+                let seplen = seplen - 1;
+                let mut buf = ::cast::transmute_mut_unsafe(buf);
+                for vec::each(v) |ss| {
+                    do as_buf(*ss) |ssbuf, sslen| {
+                        let sslen = sslen - 1;
+                        if first {
+                            first = false;
+                        } else if seplen > 0 {
+                            ptr::copy_memory(buf, sepbuf, seplen);
+                            buf = buf.offset(seplen);
+                        }
+                        ptr::copy_memory(buf, ssbuf, sslen);
+                        buf = buf.offset(sslen);
+                    }
+                }
+            }
+        }
+        raw::set_len(&mut s, len);
     }
     s
 }
 
 /// Given a string, make a new string with repeated copies of it
 pub fn repeat(ss: &str, nn: uint) -> ~str {
-    let mut acc = ~"";
-    for nn.times { acc += ss; }
-    acc
+    do as_buf(ss) |buf, len| {
+        let mut ret = ~"";
+        // ignore the NULL terminator
+        let len = len - 1;
+        reserve(&mut ret, nn * len);
+
+        unsafe {
+            do as_buf(ret) |rbuf, _len| {
+                let mut rbuf = ::cast::transmute_mut_unsafe(rbuf);
+
+                for nn.times {
+                    ptr::copy_memory(rbuf, buf, len);
+                    rbuf = rbuf.offset(len);
+                }
+            }
+            raw::set_len(&mut ret, nn * len);
+        }
+        ret
+    }
 }
 
 /*
@@ -820,6 +915,7 @@ Section: Comparing strings
 /// Bytewise slice equality
 #[cfg(notest)]
 #[lang="str_eq"]
+#[inline]
 pub fn eq_slice(a: &str, b: &str) -> bool {
     do as_buf(a) |ap, alen| {
         do as_buf(b) |bp, blen| {
@@ -836,6 +932,7 @@ pub fn eq_slice(a: &str, b: &str) -> bool {
 }
 
 #[cfg(test)]
+#[inline]
 pub fn eq_slice(a: &str, b: &str) -> bool {
     do as_buf(a) |ap, alen| {
         do as_buf(b) |bp, blen| {
@@ -854,15 +951,18 @@ pub fn eq_slice(a: &str, b: &str) -> bool {
 /// Bytewise string equality
 #[cfg(notest)]
 #[lang="uniq_str_eq"]
+#[inline]
 pub fn eq(a: &~str, b: &~str) -> bool {
     eq_slice(*a, *b)
 }
 
 #[cfg(test)]
+#[inline]
 pub fn eq(a: &~str, b: &~str) -> bool {
     eq_slice(*a, *b)
 }
 
+#[inline]
 fn cmp(a: &str, b: &str) -> Ordering {
     let low = uint::min(a.len(), b.len());
 
@@ -879,20 +979,24 @@ fn cmp(a: &str, b: &str) -> Ordering {
 
 #[cfg(notest)]
 impl<'self> TotalOrd for &'self str {
+    #[inline]
     fn cmp(&self, other: & &'self str) -> Ordering { cmp(*self, *other) }
 }
 
 #[cfg(notest)]
 impl TotalOrd for ~str {
+    #[inline]
     fn cmp(&self, other: &~str) -> Ordering { cmp(*self, *other) }
 }
 
 #[cfg(notest)]
 impl TotalOrd for @str {
+    #[inline]
     fn cmp(&self, other: &@str) -> Ordering { cmp(*self, *other) }
 }
 
 /// Bytewise slice less than
+#[inline]
 fn lt(a: &str, b: &str) -> bool {
     let (a_len, b_len) = (a.len(), b.len());
     let end = uint::min(a_len, b_len);
@@ -909,16 +1013,19 @@ fn lt(a: &str, b: &str) -> bool {
 }
 
 /// Bytewise less than or equal
+#[inline]
 pub fn le(a: &str, b: &str) -> bool {
     !lt(b, a)
 }
 
 /// Bytewise greater than or equal
+#[inline]
 fn ge(a: &str, b: &str) -> bool {
     !lt(a, b)
 }
 
 /// Bytewise greater than
+#[inline]
 fn gt(a: &str, b: &str) -> bool {
     !le(a, b)
 }
@@ -1595,6 +1702,7 @@ Section: String properties
 */
 
 /// Returns true if the string has length 0
+#[inline(always)]
 pub fn is_empty(s: &str) -> bool { len(s) == 0u }
 
 /**
@@ -1616,11 +1724,13 @@ fn is_alphanumeric(s: &str) -> bool {
 }
 
 /// Returns the string length/size in bytes not counting the null terminator
+#[inline(always)]
 pub fn len(s: &str) -> uint {
     do as_buf(s) |_p, n| { n - 1u }
 }
 
 /// Returns the number of characters that a string holds
+#[inline(always)]
 pub fn char_len(s: &str) -> uint { count_chars(s, 0u, len(s)) }
 
 /*
@@ -1752,7 +1862,8 @@ pub fn count_chars(s: &str, start: uint, end: uint) -> uint {
     return len;
 }
 
-/// Counts the number of bytes taken by the `n` in `s` starting from `start`.
+/// Counts the number of bytes taken by the first `n` chars in `s`
+/// starting from `start`.
 pub fn count_bytes<'b>(s: &'b str, start: uint, n: uint) -> uint {
     assert!(is_char_boundary(s, start));
     let mut end = start, cnt = n;
@@ -1988,6 +2099,7 @@ static tag_six_b: uint = 252u;
  * let i = str::as_bytes("Hello World") { |bytes| vec::len(bytes) };
  * ~~~
  */
+#[inline]
 pub fn as_bytes<T>(s: &const ~str, f: &fn(&~[u8]) -> T) -> T {
     unsafe {
         let v: *~[u8] = cast::transmute(copy s);
@@ -2023,6 +2135,7 @@ pub fn as_bytes_slice<'a>(s: &'a str) -> &'a [u8] {
  * let s = str::as_c_str("PATH", { |path| libc::getenv(path) });
  * ~~~
  */
+#[inline]
 pub fn as_c_str<T>(s: &str, f: &fn(*libc::c_char) -> T) -> T {
     do as_buf(s) |buf, len| {
         // NB: len includes the trailing null.
@@ -2099,6 +2212,7 @@ pub fn subslice_offset(outer: &str, inner: &str) -> uint {
  * * s - A string
  * * n - The number of bytes to reserve space for
  */
+#[inline(always)]
 pub fn reserve(s: &mut ~str, n: uint) {
     unsafe {
         let v: *mut ~[u8] = cast::transmute(s);
@@ -2126,6 +2240,7 @@ pub fn reserve(s: &mut ~str, n: uint) {
  * * s - A string
  * * n - The number of bytes to reserve space for
  */
+#[inline(always)]
 pub fn reserve_at_least(s: &mut ~str, n: uint) {
     reserve(s, uint::next_power_of_two(n + 1u) - 1u)
 }
@@ -2314,6 +2429,7 @@ pub mod raw {
     }
 
     /// Sets the length of the string and adds the null terminator
+    #[inline]
     pub unsafe fn set_len(v: &mut ~str, new_len: uint) {
         let v: **mut vec::raw::VecRepr = cast::transmute(v);
         let repr: *mut vec::raw::VecRepr = *v;
@@ -2483,7 +2599,7 @@ impl<'self> StrSlice<'self> for &'self str {
     #[inline]
     fn is_alphanumeric(&self) -> bool { is_alphanumeric(*self) }
     /// Returns the size in bytes not counting the null terminator
-    #[inline]
+    #[inline(always)]
     fn len(&self) -> uint { len(*self) }
     /// Returns the number of characters that a string holds
     #[inline]
@@ -2593,10 +2709,11 @@ pub trait OwnedStr {
 }
 
 impl OwnedStr for ~str {
+    #[inline]
     fn push_str(&mut self, v: &str) {
         push_str(self, v);
     }
-
+    #[inline]
     fn push_char(&mut self, c: char) {
         push_char(self, c);
     }
diff --git a/src/libcore/str/ascii.rs b/src/libcore/str/ascii.rs
index 9180c995ca2..73f556518fa 100644
--- a/src/libcore/str/ascii.rs
+++ b/src/libcore/str/ascii.rs
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+//! Operations on ASCII strings and characters.
+
 use to_str::{ToStr,ToStrConsume};
 use str;
 use cast;
diff --git a/src/libcore/sys.rs b/src/libcore/sys.rs
index 8cad0a22886..4eca7ebbb37 100644
--- a/src/libcore/sys.rs
+++ b/src/libcore/sys.rs
@@ -10,6 +10,7 @@
 
 //! Misc low level stuff
 
+use option::{Some, None};
 use cast;
 use cmp::{Eq, Ord};
 use gc;
@@ -199,36 +200,33 @@ impl FailWithCause for &'static str {
     }
 }
 
-// NOTE: remove function after snapshot
-#[cfg(stage0)]
-pub fn begin_unwind(msg: ~str, file: ~str, line: uint) -> ! {
-    do str::as_buf(msg) |msg_buf, _msg_len| {
-        do str::as_buf(file) |file_buf, _file_len| {
+// FIXME #4427: Temporary until rt::rt_fail_ goes away
+pub fn begin_unwind_(msg: *c_char, file: *c_char, line: size_t) -> ! {
+    use rt::{context, OldTaskContext};
+    use rt::local_services::unsafe_borrow_local_services;
+
+    match context() {
+        OldTaskContext => {
             unsafe {
-                let msg_buf = cast::transmute(msg_buf);
-                let file_buf = cast::transmute(file_buf);
-                begin_unwind_(msg_buf, file_buf, line as libc::size_t)
+                gc::cleanup_stack_for_failure();
+                rustrt::rust_upcall_fail(msg, file, line);
+                cast::transmute(())
+            }
+        }
+        _ => {
+            // XXX: Need to print the failure message
+            gc::cleanup_stack_for_failure();
+            unsafe {
+                let local_services = unsafe_borrow_local_services();
+                match local_services.unwinder {
+                    Some(ref mut unwinder) => unwinder.begin_unwind(),
+                    None => abort!("failure without unwinder. aborting process")
+                }
             }
         }
     }
 }
 
-// FIXME #4427: Temporary until rt::rt_fail_ goes away
-pub fn begin_unwind_(msg: *c_char, file: *c_char, line: size_t) -> ! {
-    unsafe {
-        gc::cleanup_stack_for_failure();
-        rustrt::rust_upcall_fail(msg, file, line);
-        cast::transmute(())
-    }
-}
-
-// NOTE: remove function after snapshot
-#[cfg(stage0)]
-pub fn fail_assert(msg: &str, file: &str, line: uint) -> ! {
-    let (msg, file) = (msg.to_owned(), file.to_owned());
-    begin_unwind(~"assertion failed: " + msg, file, line)
-}
-
 #[cfg(test)]
 mod tests {
     use cast;
@@ -343,11 +341,3 @@ mod tests {
     #[should_fail]
     fn fail_owned() { FailWithCause::fail_with(~"cause", file!(), line!())  }
 }
-
-// Local Variables:
-// mode: rust;
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
diff --git a/src/libcore/task/local_data.rs b/src/libcore/task/local_data.rs
index 6050aca6dc1..dff5908c047 100644
--- a/src/libcore/task/local_data.rs
+++ b/src/libcore/task/local_data.rs
@@ -27,8 +27,7 @@ magic.
 */
 
 use prelude::*;
-use task::local_data_priv::{local_get, local_pop, local_modify, local_set};
-use task::rt;
+use task::local_data_priv::{local_get, local_pop, local_modify, local_set, Handle};
 
 /**
  * Indexes a task-local data slot. The function's code pointer is used for
@@ -53,7 +52,7 @@ pub type LocalDataKey<'self,T> = &'self fn(v: @T);
 pub unsafe fn local_data_pop<T:Durable>(
     key: LocalDataKey<T>) -> Option<@T> {
 
-    local_pop(rt::rust_get_task(), key)
+    local_pop(Handle::new(), key)
 }
 /**
  * Retrieve a task-local data value. It will also be kept alive in the
@@ -62,7 +61,7 @@ pub unsafe fn local_data_pop<T:Durable>(
 pub unsafe fn local_data_get<T:Durable>(
     key: LocalDataKey<T>) -> Option<@T> {
 
-    local_get(rt::rust_get_task(), key)
+    local_get(Handle::new(), key)
 }
 /**
  * Store a value in task-local data. If this key already has a value,
@@ -71,7 +70,7 @@ pub unsafe fn local_data_get<T:Durable>(
 pub unsafe fn local_data_set<T:Durable>(
     key: LocalDataKey<T>, data: @T) {
 
-    local_set(rt::rust_get_task(), key, data)
+    local_set(Handle::new(), key, data)
 }
 /**
  * Modify a task-local data value. If the function returns 'None', the
@@ -81,7 +80,7 @@ pub unsafe fn local_data_modify<T:Durable>(
     key: LocalDataKey<T>,
     modify_fn: &fn(Option<@T>) -> Option<@T>) {
 
-    local_modify(rt::rust_get_task(), key, modify_fn)
+    local_modify(Handle::new(), key, modify_fn)
 }
 
 #[test]
diff --git a/src/libcore/task/local_data_priv.rs b/src/libcore/task/local_data_priv.rs
index 67bc3adeb41..10a40887e57 100644
--- a/src/libcore/task/local_data_priv.rs
+++ b/src/libcore/task/local_data_priv.rs
@@ -18,6 +18,30 @@ use task::rt;
 use task::local_data::LocalDataKey;
 
 use super::rt::rust_task;
+use rt::local_services::LocalStorage;
+
+pub enum Handle {
+    OldHandle(*rust_task),
+    NewHandle(*mut LocalStorage)
+}
+
+impl Handle {
+    pub fn new() -> Handle {
+        use rt::{context, OldTaskContext};
+        use rt::local_services::unsafe_borrow_local_services;
+        unsafe {
+            match context() {
+                OldTaskContext => {
+                    OldHandle(rt::rust_get_task())
+                }
+                _ => {
+                    let local_services = unsafe_borrow_local_services();
+                    NewHandle(&mut local_services.storage)
+                }
+            }
+        }
+    }
+}
 
 pub trait LocalData { }
 impl<T:Durable> LocalData for @T { }
@@ -25,8 +49,8 @@ impl<T:Durable> LocalData for @T { }
 impl Eq for @LocalData {
     fn eq(&self, other: &@LocalData) -> bool {
         unsafe {
-            let ptr_a: (uint, uint) = cast::transmute(*self);
-            let ptr_b: (uint, uint) = cast::transmute(*other);
+            let ptr_a: &(uint, uint) = cast::transmute(self);
+            let ptr_b: &(uint, uint) = cast::transmute(other);
             return ptr_a == ptr_b;
         }
     }
@@ -39,7 +63,7 @@ type TaskLocalElement = (*libc::c_void, *libc::c_void, @LocalData);
 // Has to be a pointer at outermost layer; the foreign call returns void *.
 type TaskLocalMap = @mut ~[Option<TaskLocalElement>];
 
-extern fn cleanup_task_local_map(map_ptr: *libc::c_void) {
+fn cleanup_task_local_map(map_ptr: *libc::c_void) {
     unsafe {
         assert!(!map_ptr.is_null());
         // Get and keep the single reference that was created at the
@@ -50,8 +74,19 @@ extern fn cleanup_task_local_map(map_ptr: *libc::c_void) {
 }
 
 // Gets the map from the runtime. Lazily initialises if not done so already.
+unsafe fn get_local_map(handle: Handle) -> TaskLocalMap {
+    match handle {
+        OldHandle(task) => get_task_local_map(task),
+        NewHandle(local_storage) => get_newsched_local_map(local_storage)
+    }
+}
+
 unsafe fn get_task_local_map(task: *rust_task) -> TaskLocalMap {
 
+    extern fn cleanup_task_local_map_extern_cb(map_ptr: *libc::c_void) {
+        cleanup_task_local_map(map_ptr);
+    }
+
     // Relies on the runtime initialising the pointer to null.
     // Note: The map's box lives in TLS invisibly referenced once. Each time
     // we retrieve it for get/set, we make another reference, which get/set
@@ -60,7 +95,7 @@ unsafe fn get_task_local_map(task: *rust_task) -> TaskLocalMap {
     if map_ptr.is_null() {
         let map: TaskLocalMap = @mut ~[];
         rt::rust_set_task_local_data(task, cast::transmute(map));
-        rt::rust_task_local_data_atexit(task, cleanup_task_local_map);
+        rt::rust_task_local_data_atexit(task, cleanup_task_local_map_extern_cb);
         // Also need to reference it an extra time to keep it for now.
         let nonmut = cast::transmute::<TaskLocalMap,
                                        @~[Option<TaskLocalElement>]>(map);
@@ -75,6 +110,27 @@ unsafe fn get_task_local_map(task: *rust_task) -> TaskLocalMap {
     }
 }
 
+unsafe fn get_newsched_local_map(local: *mut LocalStorage) -> TaskLocalMap {
+    match &mut *local {
+        &LocalStorage(map_ptr, Some(_)) => {
+            assert!(map_ptr.is_not_null());
+            let map = cast::transmute(map_ptr);
+            let nonmut = cast::transmute::<TaskLocalMap,
+            @~[Option<TaskLocalElement>]>(map);
+            cast::bump_box_refcount(nonmut);
+            return map;
+        }
+        &LocalStorage(ref mut map_ptr, ref mut at_exit) => {
+            assert!((*map_ptr).is_null());
+            let map: TaskLocalMap = @mut ~[];
+            *map_ptr = cast::transmute(map);
+            let at_exit_fn: ~fn(*libc::c_void) = |p|cleanup_task_local_map(p);
+            *at_exit = Some(at_exit_fn);
+            return map;
+        }
+    }
+}
+
 unsafe fn key_to_key_value<T:Durable>(key: LocalDataKey<T>) -> *libc::c_void {
     // Keys are closures, which are (fnptr,envptr) pairs. Use fnptr.
     // Use reintepret_cast -- transmute would leak (forget) the closure.
@@ -102,10 +158,10 @@ unsafe fn local_data_lookup<T:Durable>(
 }
 
 unsafe fn local_get_helper<T:Durable>(
-    task: *rust_task, key: LocalDataKey<T>,
+    handle: Handle, key: LocalDataKey<T>,
     do_pop: bool) -> Option<@T> {
 
-    let map = get_task_local_map(task);
+    let map = get_local_map(handle);
     // Interpreturn our findings from the map
     do local_data_lookup(map, key).map |result| {
         // A reference count magically appears on 'data' out of thin air. It
@@ -124,23 +180,23 @@ unsafe fn local_get_helper<T:Durable>(
 
 
 pub unsafe fn local_pop<T:Durable>(
-    task: *rust_task,
+    handle: Handle,
     key: LocalDataKey<T>) -> Option<@T> {
 
-    local_get_helper(task, key, true)
+    local_get_helper(handle, key, true)
 }
 
 pub unsafe fn local_get<T:Durable>(
-    task: *rust_task,
+    handle: Handle,
     key: LocalDataKey<T>) -> Option<@T> {
 
-    local_get_helper(task, key, false)
+    local_get_helper(handle, key, false)
 }
 
 pub unsafe fn local_set<T:Durable>(
-    task: *rust_task, key: LocalDataKey<T>, data: @T) {
+    handle: Handle, key: LocalDataKey<T>, data: @T) {
 
-    let map = get_task_local_map(task);
+    let map = get_local_map(handle);
     // Store key+data as *voids. Data is invisibly referenced once; key isn't.
     let keyval = key_to_key_value(key);
     // We keep the data in two forms: one as an unsafe pointer, so we can get
@@ -148,7 +204,7 @@ pub unsafe fn local_set<T:Durable>(
     // own on it can be dropped when the box is destroyed. The unsafe pointer
     // does not have a reference associated with it, so it may become invalid
     // when the box is destroyed.
-    let data_ptr = cast::transmute(data);
+    let data_ptr = *cast::transmute::<&@T, &*libc::c_void>(&data);
     let data_box = @data as @LocalData;
     // Construct new entry to store in the map.
     let new_entry = Some((keyval, data_ptr, data_box));
@@ -170,12 +226,12 @@ pub unsafe fn local_set<T:Durable>(
 }
 
 pub unsafe fn local_modify<T:Durable>(
-    task: *rust_task, key: LocalDataKey<T>,
+    handle: Handle, key: LocalDataKey<T>,
     modify_fn: &fn(Option<@T>) -> Option<@T>) {
 
     // Could be more efficient by doing the lookup work, but this is easy.
-    let newdata = modify_fn(local_pop(task, key));
+    let newdata = modify_fn(local_pop(handle, key));
     if newdata.is_some() {
-        local_set(task, key, newdata.unwrap());
+        local_set(handle, key, newdata.unwrap());
     }
 }
diff --git a/src/libcore/task/mod.rs b/src/libcore/task/mod.rs
index 96429932b18..fd695c16ea7 100644
--- a/src/libcore/task/mod.rs
+++ b/src/libcore/task/mod.rs
@@ -39,9 +39,10 @@ use result::Result;
 use comm::{stream, Chan, GenericChan, GenericPort, Port};
 use prelude::*;
 use result;
-use task::rt::{task_id, sched_id, rust_task};
+use task::rt::{task_id, sched_id};
 use util;
 use util::replace;
+use unstable::finally::Finally;
 
 #[cfg(test)] use comm::SharedChan;
 
@@ -558,8 +559,31 @@ pub fn yield() {
 pub fn failing() -> bool {
     //! True if the running task has failed
 
-    unsafe {
-        rt::rust_task_is_unwinding(rt::rust_get_task())
+    use rt::{context, OldTaskContext};
+    use rt::local_services::borrow_local_services;
+
+    match context() {
+        OldTaskContext => {
+            unsafe {
+                rt::rust_task_is_unwinding(rt::rust_get_task())
+            }
+        }
+        _ => {
+            let mut unwinding = false;
+            do borrow_local_services |local| {
+                unwinding = match local.unwinder {
+                    Some(unwinder) => {
+                        unwinder.unwinding
+                    }
+                    None => {
+                        // Because there is no unwinder we can't be unwinding.
+                        // (The process will abort on failure)
+                        false
+                    }
+                }
+            }
+            return unwinding;
+        }
     }
 }
 
@@ -591,48 +615,24 @@ pub fn get_scheduler() -> Scheduler {
  * ~~~
  */
 pub unsafe fn unkillable<U>(f: &fn() -> U) -> U {
-    struct AllowFailure {
-        t: *rust_task,
-        drop {
-            unsafe {
-                rt::rust_task_allow_kill(self.t);
-            }
-        }
-    }
-
-    fn AllowFailure(t: *rust_task) -> AllowFailure{
-        AllowFailure {
-            t: t
-        }
-    }
-
     let t = rt::rust_get_task();
-    let _allow_failure = AllowFailure(t);
-    rt::rust_task_inhibit_kill(t);
-    f()
+    do (|| {
+        rt::rust_task_inhibit_kill(t);
+        f()
+    }).finally {
+        rt::rust_task_allow_kill(t);
+    }
 }
 
 /// The inverse of unkillable. Only ever to be used nested in unkillable().
 pub unsafe fn rekillable<U>(f: &fn() -> U) -> U {
-    struct DisallowFailure {
-        t: *rust_task,
-        drop {
-            unsafe {
-                rt::rust_task_inhibit_kill(self.t);
-            }
-        }
-    }
-
-    fn DisallowFailure(t: *rust_task) -> DisallowFailure {
-        DisallowFailure {
-            t: t
-        }
-    }
-
     let t = rt::rust_get_task();
-    let _allow_failure = DisallowFailure(t);
-    rt::rust_task_allow_kill(t);
-    f()
+    do (|| {
+        rt::rust_task_allow_kill(t);
+        f()
+    }).finally {
+        rt::rust_task_inhibit_kill(t);
+    }
 }
 
 /**
@@ -640,27 +640,15 @@ pub unsafe fn rekillable<U>(f: &fn() -> U) -> U {
  * For use with exclusive ARCs, which use pthread mutexes directly.
  */
 pub unsafe fn atomically<U>(f: &fn() -> U) -> U {
-    struct DeferInterrupts {
-        t: *rust_task,
-        drop {
-            unsafe {
-                rt::rust_task_allow_yield(self.t);
-                rt::rust_task_allow_kill(self.t);
-            }
-        }
-    }
-
-    fn DeferInterrupts(t: *rust_task) -> DeferInterrupts {
-        DeferInterrupts {
-            t: t
-        }
-    }
-
     let t = rt::rust_get_task();
-    let _interrupts = DeferInterrupts(t);
-    rt::rust_task_inhibit_kill(t);
-    rt::rust_task_inhibit_yield(t);
-    f()
+    do (|| {
+        rt::rust_task_inhibit_kill(t);
+        rt::rust_task_inhibit_yield(t);
+        f()
+    }).finally {
+        rt::rust_task_allow_yield(t);
+        rt::rust_task_allow_kill(t);
+    }
 }
 
 #[test] #[should_fail] #[ignore(cfg(windows))]
@@ -832,7 +820,7 @@ fn test_run_basic() {
     po.recv();
 }
 
-#[test]
+#[cfg(test)]
 struct Wrapper {
     mut f: Option<Chan<()>>
 }
@@ -1229,7 +1217,7 @@ fn test_spawn_thread_on_demand() {
 
 #[test]
 fn test_simple_newsched_spawn() {
-    use rt::run_in_newsched_task;
+    use rt::test::run_in_newsched_task;
 
     do run_in_newsched_task {
         spawn(||())
diff --git a/src/libcore/task/spawn.rs b/src/libcore/task/spawn.rs
index 507643ea5ec..267250b3642 100644
--- a/src/libcore/task/spawn.rs
+++ b/src/libcore/task/spawn.rs
@@ -80,7 +80,7 @@ use prelude::*;
 use unstable;
 use ptr;
 use hashmap::HashSet;
-use task::local_data_priv::{local_get, local_set};
+use task::local_data_priv::{local_get, local_set, OldHandle};
 use task::rt::rust_task;
 use task::rt;
 use task::{Failure, ManualThreads, PlatformThread, SchedOpts, SingleThreaded};
@@ -451,7 +451,7 @@ fn gen_child_taskgroup(linked: bool, supervised: bool)
         /*##################################################################*
          * Step 1. Get spawner's taskgroup info.
          *##################################################################*/
-        let spawner_group = match local_get(spawner, taskgroup_key!()) {
+        let spawner_group = match local_get(OldHandle(spawner), taskgroup_key!()) {
             None => {
                 // Main task, doing first spawn ever. Lazily initialise here.
                 let mut members = new_taskset();
@@ -463,7 +463,7 @@ fn gen_child_taskgroup(linked: bool, supervised: bool)
                 // Main task/group has no ancestors, no notifier, etc.
                 let group =
                     @TCB(spawner, tasks, AncestorList(None), true, None);
-                local_set(spawner, taskgroup_key!(), group);
+                local_set(OldHandle(spawner), taskgroup_key!(), group);
                 group
             }
             Some(group) => group
@@ -627,7 +627,7 @@ fn spawn_raw_oldsched(opts: TaskOpts, f: ~fn()) {
                 let group = @TCB(child, child_arc, ancestors,
                                  is_main, notifier);
                 unsafe {
-                    local_set(child, taskgroup_key!(), group);
+                    local_set(OldHandle(child), taskgroup_key!(), group);
                 }
 
                 // Run the child's body.
diff --git a/src/libcore/to_bytes.rs b/src/libcore/to_bytes.rs
index 63dcf0f44dc..9e4da7ab488 100644
--- a/src/libcore/to_bytes.rs
+++ b/src/libcore/to_bytes.rs
@@ -419,8 +419,7 @@ impl<A> IterBytes for *const A {
     }
 }
 
-
-trait ToBytes {
+pub trait ToBytes {
     fn to_bytes(&self, lsb0: bool) -> ~[u8];
 }
 
diff --git a/src/libcore/unicode.rs b/src/libcore/unicode.rs
index a13d66c48ee..d6e2c5eee6a 100644
--- a/src/libcore/unicode.rs
+++ b/src/libcore/unicode.rs
@@ -10,6 +10,8 @@
 
 #[doc(hidden)]; // FIXME #3538
 
+// The following code was generated by "src/etc/unicode.py"
+
 pub mod general_category {
 
     fn bsearch_range_table(c: char, r: &'static [(char,char)]) -> bool {
@@ -2640,4 +2642,3 @@ pub mod derived_property {
         bsearch_range_table(c, XID_Start_table)
     }
 }
-
diff --git a/src/libcore/unstable/exchange_alloc.rs b/src/libcore/unstable/exchange_alloc.rs
index 8ca5486d929..57ed579e88d 100644
--- a/src/libcore/unstable/exchange_alloc.rs
+++ b/src/libcore/unstable/exchange_alloc.rs
@@ -81,4 +81,3 @@ extern {
     #[rust_stack]
     fn rust_get_exchange_count_ptr() -> *mut int;
 }
-
diff --git a/src/libcore/unstable/extfmt.rs b/src/libcore/unstable/extfmt.rs
index e5d32c4bb32..258da9ff383 100644
--- a/src/libcore/unstable/extfmt.rs
+++ b/src/libcore/unstable/extfmt.rs
@@ -688,11 +688,3 @@ mod test {
         let _s = fmt!("%s", s);
     }
 }
-
-// Local Variables:
-// mode: rust;
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
diff --git a/src/libcore/unstable/intrinsics.rs b/src/libcore/unstable/intrinsics.rs
index b58429a10aa..65cfc6ec1fe 100644
--- a/src/libcore/unstable/intrinsics.rs
+++ b/src/libcore/unstable/intrinsics.rs
@@ -46,10 +46,6 @@ pub extern "rust-intrinsic" {
 
     pub fn forget<T>(_: T) -> ();
 
-    // XXX: intrinsic uses legacy modes
-    #[cfg(stage0)]
-    fn reinterpret_cast<T,U>(&&src: T) -> U;
-
     pub fn needs_drop<T>() -> bool;
 
     // XXX: intrinsic uses legacy modes and has reference to TyDesc
diff --git a/src/libcore/unstable/lang.rs b/src/libcore/unstable/lang.rs
index 6b61df31fdc..deff06d46f6 100644
--- a/src/libcore/unstable/lang.rs
+++ b/src/libcore/unstable/lang.rs
@@ -18,9 +18,11 @@ use str;
 use sys;
 use unstable::exchange_alloc;
 use cast::transmute;
-use task::rt::rust_get_task;
+use rt::{context, OldTaskContext};
+use rt::local_services::borrow_local_services;
 use option::{Option, Some, None};
 use io;
+use task::rt::rust_get_task;
 
 #[allow(non_camel_case_types)]
 pub type rust_task = c_void;
@@ -249,21 +251,36 @@ pub unsafe fn exchange_free(ptr: *c_char) {
 }
 
 #[lang="malloc"]
-#[inline(always)]
 pub unsafe fn local_malloc(td: *c_char, size: uintptr_t) -> *c_char {
-    let result = rustrt::rust_upcall_malloc_noswitch(td, size);
-    debug_mem("local_malloc: ", result);
-    return result;
+    match context() {
+        OldTaskContext => {
+            return rustrt::rust_upcall_malloc_noswitch(td, size);
+        }
+        _ => {
+            let mut alloc = ::ptr::null();
+            do borrow_local_services |srv| {
+                alloc = srv.heap.alloc(td as *c_void, size as uint) as *c_char;
+            }
+            return alloc;
+        }
+    }
 }
 
 // NB: Calls to free CANNOT be allowed to fail, as throwing an exception from
 // inside a landing pad may corrupt the state of the exception handler. If a
 // problem occurs, call exit instead.
 #[lang="free"]
-#[inline(always)]
 pub unsafe fn local_free(ptr: *c_char) {
-    debug_mem("local_free: ", ptr);
-    rustrt::rust_upcall_free_noswitch(ptr);
+    match context() {
+        OldTaskContext => {
+            rustrt::rust_upcall_free_noswitch(ptr);
+        }
+        _ => {
+            do borrow_local_services |srv| {
+                srv.heap.free(ptr as *c_void);
+            }
+        }
+    }
 }
 
 #[cfg(stage0)]
@@ -444,11 +461,3 @@ pub fn start(main: *u8, argc: int, argv: **c_char,
                       crate_map: *c_void) -> c_int;
     }
 }
-
-// Local Variables:
-// mode: rust;
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
diff --git a/src/libcore/unstable/weak_task.rs b/src/libcore/unstable/weak_task.rs
index 7a30bb92111..6edbdcb51b0 100644
--- a/src/libcore/unstable/weak_task.rs
+++ b/src/libcore/unstable/weak_task.rs
@@ -205,4 +205,3 @@ fn test_select_stream_and_oneshot() {
     chan.send(());
     waitport.recv();
 }
-
diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs
index 4c817da0819..ced3c300a35 100644
--- a/src/libcore/vec.rs
+++ b/src/libcore/vec.rs
@@ -134,9 +134,9 @@ pub fn uniq_len<T>(v: &const ~[T]) -> uint {
 }
 
 /**
- * Creates and initializes an immutable vector.
+ * Creates and initializes an owned vector.
  *
- * Creates an immutable vector of size `n_elts` and initializes the elements
+ * Creates an owned vector of size `n_elts` and initializes the elements
  * to the value returned by the function `op`.
  */
 pub fn from_fn<T>(n_elts: uint, op: old_iter::InitOp<T>) -> ~[T] {
@@ -156,9 +156,9 @@ pub fn from_fn<T>(n_elts: uint, op: old_iter::InitOp<T>) -> ~[T] {
 }
 
 /**
- * Creates and initializes an immutable vector.
+ * Creates and initializes an owned vector.
  *
- * Creates an immutable vector of size `n_elts` and initializes the elements
+ * Creates an owned vector of size `n_elts` and initializes the elements
  * to the value `t`.
  */
 pub fn from_elem<T:Copy>(n_elts: uint, t: T) -> ~[T] {
diff --git a/src/libfuzzer/fuzzer.rc b/src/libfuzzer/fuzzer.rc
index fc1efd3313c..7c93d867f50 100644
--- a/src/libfuzzer/fuzzer.rc
+++ b/src/libfuzzer/fuzzer.rc
@@ -693,10 +693,3 @@ pub fn main() {
 
     error!("Fuzzer done");
 }
-
-// Local Variables:
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
diff --git a/src/librustc/back/abi.rs b/src/librustc/back/abi.rs
index 70a029ede6f..e722e1a33c6 100644
--- a/src/librustc/back/abi.rs
+++ b/src/librustc/back/abi.rs
@@ -57,6 +57,13 @@ pub static n_tydesc_fields: uint = 8u;
 pub static fn_field_code: uint = 0u;
 pub static fn_field_box: uint = 1u;
 
+// The three fields of a trait object/trait instance: vtable, box, and type
+// description.
+pub static trt_field_vtable: uint = 0u;
+pub static trt_field_box: uint = 1u;
+// This field is only present in unique trait objects, so it comes last.
+pub static trt_field_tydesc: uint = 2u;
+
 pub static vec_elt_fill: uint = 0u;
 
 pub static vec_elt_alloc: uint = 1u;
@@ -77,12 +84,3 @@ pub fn bzero_glue_name() -> ~str { return ~"rust_bzero_glue"; }
 pub fn yield_glue_name() -> ~str { return ~"rust_yield_glue"; }
 
 pub fn no_op_type_glue_name() -> ~str { return ~"rust_no_op_type_glue"; }
-//
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
-//
diff --git a/src/librustc/back/arm.rs b/src/librustc/back/arm.rs
index 97c3a588a7f..dfe5751f21b 100644
--- a/src/librustc/back/arm.rs
+++ b/src/librustc/back/arm.rs
@@ -72,14 +72,3 @@ pub fn get_target_strs(target_os: session::os) -> target_strs::t {
         cc_args: ~[~"-marm"]
     };
 }
-
-
-//
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
-//
diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs
index 8c442f2d5c9..de6469e8180 100644
--- a/src/librustc/back/link.rs
+++ b/src/librustc/back/link.rs
@@ -747,6 +747,79 @@ pub fn link_binary(sess: Session,
                    obj_filename: &Path,
                    out_filename: &Path,
                    lm: LinkMeta) {
+    // In the future, FreeBSD will use clang as default compiler.
+    // It would be flexible to use cc (system's default C compiler)
+    // instead of hard-coded gcc.
+    // For win32, there is no cc command,
+    // so we add a condition to make it use gcc.
+    let cc_prog: ~str = match sess.opts.linker {
+        Some(copy linker) => linker,
+        None => {
+            if sess.targ_cfg.os == session::os_android {
+                match &sess.opts.android_cross_path {
+                    &Some(copy path) => {
+                        fmt!("%s/bin/arm-linux-androideabi-gcc", path)
+                    }
+                    &None => {
+                        sess.fatal(~"need Android NDK path for linking \
+                                     (--android-cross-path)")
+                    }
+                }
+            } else if sess.targ_cfg.os == session::os_win32 {
+                ~"gcc"
+            } else {
+                ~"cc"
+            }
+        }
+    };
+    // The invocations of cc share some flags across platforms
+
+
+    let output = if *sess.building_library {
+        let long_libname = output_dll_filename(sess.targ_cfg.os, lm);
+        debug!("link_meta.name:  %s", lm.name);
+        debug!("long_libname: %s", long_libname);
+        debug!("out_filename: %s", out_filename.to_str());
+        debug!("dirname(out_filename): %s", out_filename.dir_path().to_str());
+
+        out_filename.dir_path().push(long_libname)
+    } else {
+        /*bad*/copy *out_filename
+    };
+
+    debug!("output: %s", output.to_str());
+    let mut cc_args = link_args(sess, obj_filename, out_filename, lm);
+    debug!("%s link args: %s", cc_prog, str::connect(cc_args, ~" "));
+    // We run 'cc' here
+    let prog = run::program_output(cc_prog, cc_args);
+    if 0 != prog.status {
+        sess.err(fmt!("linking with `%s` failed with code %d",
+                      cc_prog, prog.status));
+        sess.note(fmt!("%s arguments: %s",
+                       cc_prog, str::connect(cc_args, ~" ")));
+        sess.note(prog.err + prog.out);
+        sess.abort_if_errors();
+    }
+
+    // Clean up on Darwin
+    if sess.targ_cfg.os == session::os_macos {
+        run::run_program(~"dsymutil", ~[output.to_str()]);
+    }
+
+    // Remove the temporary object file if we aren't saving temps
+    if !sess.opts.save_temps {
+        if ! os::remove_file(obj_filename) {
+            sess.warn(fmt!("failed to delete object file `%s`",
+                           obj_filename.to_str()));
+        }
+    }
+}
+
+pub fn link_args(sess: Session,
+                 obj_filename: &Path,
+                 out_filename: &Path,
+                 lm:LinkMeta) -> ~[~str] {
+
     // Converts a library file-stem into a cc -l argument
     fn unlib(config: @session::config, stem: ~str) -> ~str {
         if stem.starts_with("lib") &&
@@ -757,48 +830,23 @@ pub fn link_binary(sess: Session,
         }
     }
 
+
     let output = if *sess.building_library {
         let long_libname = output_dll_filename(sess.targ_cfg.os, lm);
-        debug!("link_meta.name:  %s", lm.name);
-        debug!("long_libname: %s", long_libname);
-        debug!("out_filename: %s", out_filename.to_str());
-        debug!("dirname(out_filename): %s", out_filename.dir_path().to_str());
-
         out_filename.dir_path().push(long_libname)
     } else {
         /*bad*/copy *out_filename
     };
 
-    debug!("output: %s", output.to_str());
-
     // The default library location, we need this to find the runtime.
     // The location of crates will be determined as needed.
     let stage: ~str = ~"-L" + sess.filesearch.get_target_lib_path().to_str();
 
-    // In the future, FreeBSD will use clang as default compiler.
-    // It would be flexible to use cc (system's default C compiler)
-    // instead of hard-coded gcc.
-    // For win32, there is no cc command,
-    // so we add a condition to make it use gcc.
-    let cc_prog: ~str = if sess.targ_cfg.os == session::os_android {
-        match &sess.opts.android_cross_path {
-            &Some(copy path) => {
-                fmt!("%s/bin/arm-linux-androideabi-gcc", path)
-            }
-            &None => {
-                sess.fatal(~"need Android NDK path for linking \
-                             (--android-cross-path)")
-            }
-        }
-    } else if sess.targ_cfg.os == session::os_win32 { ~"gcc" }
-    else { ~"cc" };
-    // The invocations of cc share some flags across platforms
+    let mut args = vec::append(~[stage], sess.targ_cfg.target_strs.cc_args);
 
-    let mut cc_args =
-        vec::append(~[stage], sess.targ_cfg.target_strs.cc_args);
-    cc_args.push(~"-o");
-    cc_args.push(output.to_str());
-    cc_args.push(obj_filename.to_str());
+    args.push(~"-o");
+    args.push(output.to_str());
+    args.push(obj_filename.to_str());
 
     let lib_cmd;
     let os = sess.targ_cfg.os;
@@ -813,23 +861,23 @@ pub fn link_binary(sess: Session,
     let cstore = sess.cstore;
     for cstore::get_used_crate_files(cstore).each |cratepath| {
         if cratepath.filetype() == Some(~".rlib") {
-            cc_args.push(cratepath.to_str());
+            args.push(cratepath.to_str());
             loop;
         }
         let dir = cratepath.dirname();
-        if dir != ~"" { cc_args.push(~"-L" + dir); }
+        if dir != ~"" { args.push(~"-L" + dir); }
         let libarg = unlib(sess.targ_cfg, cratepath.filestem().get());
-        cc_args.push(~"-l" + libarg);
+        args.push(~"-l" + libarg);
     }
 
     let ula = cstore::get_used_link_args(cstore);
-    for ula.each |arg| { cc_args.push(/*bad*/copy *arg); }
+    for ula.each |arg| { args.push(/*bad*/copy *arg); }
 
     // Add all the link args for external crates.
     do cstore::iter_crate_data(cstore) |crate_num, _| {
         let link_args = csearch::get_link_args_for_crate(cstore, crate_num);
         do vec::consume(link_args) |_, link_arg| {
-            cc_args.push(link_arg);
+            args.push(link_arg);
         }
     }
 
@@ -842,20 +890,20 @@ pub fn link_binary(sess: Session,
     // forces to make sure that library can be found at runtime.
 
     for sess.opts.addl_lib_search_paths.each |path| {
-        cc_args.push(~"-L" + path.to_str());
+        args.push(~"-L" + path.to_str());
     }
 
     // The names of the extern libraries
     let used_libs = cstore::get_used_libraries(cstore);
-    for used_libs.each |l| { cc_args.push(~"-l" + *l); }
+    for used_libs.each |l| { args.push(~"-l" + *l); }
 
     if *sess.building_library {
-        cc_args.push(lib_cmd);
+        args.push(lib_cmd);
 
         // On mac we need to tell the linker to let this library
         // be rpathed
         if sess.targ_cfg.os == session::os_macos {
-            cc_args.push(~"-Wl,-install_name,@rpath/"
+            args.push(~"-Wl,-install_name,@rpath/"
                       + output.filename().get());
         }
     }
@@ -863,27 +911,27 @@ pub fn link_binary(sess: Session,
     // On linux librt and libdl are an indirect dependencies via rustrt,
     // and binutils 2.22+ won't add them automatically
     if sess.targ_cfg.os == session::os_linux {
-        cc_args.push_all(~[~"-lrt", ~"-ldl"]);
+        args.push_all(~[~"-lrt", ~"-ldl"]);
 
         // LLVM implements the `frem` instruction as a call to `fmod`,
         // which lives in libm. Similar to above, on some linuxes we
         // have to be explicit about linking to it. See #2510
-        cc_args.push(~"-lm");
+        args.push(~"-lm");
     }
     else if sess.targ_cfg.os == session::os_android {
-        cc_args.push_all(~[~"-ldl", ~"-llog",  ~"-lsupc++",
+        args.push_all(~[~"-ldl", ~"-llog",  ~"-lsupc++",
                            ~"-lgnustl_shared"]);
-        cc_args.push(~"-lm");
+        args.push(~"-lm");
     }
 
     if sess.targ_cfg.os == session::os_freebsd {
-        cc_args.push_all(~[~"-pthread", ~"-lrt",
-                                ~"-L/usr/local/lib", ~"-lexecinfo",
-                                ~"-L/usr/local/lib/gcc46",
-                                ~"-L/usr/local/lib/gcc44", ~"-lstdc++",
-                                ~"-Wl,-z,origin",
-                                ~"-Wl,-rpath,/usr/local/lib/gcc46",
-                                ~"-Wl,-rpath,/usr/local/lib/gcc44"]);
+        args.push_all(~[~"-pthread", ~"-lrt",
+                        ~"-L/usr/local/lib", ~"-lexecinfo",
+                        ~"-L/usr/local/lib/gcc46",
+                        ~"-L/usr/local/lib/gcc44", ~"-lstdc++",
+                        ~"-Wl,-z,origin",
+                        ~"-Wl,-rpath,/usr/local/lib/gcc46",
+                        ~"-Wl,-rpath,/usr/local/lib/gcc44"]);
     }
 
     // OS X 10.6 introduced 'compact unwind info', which is produced by the
@@ -891,50 +939,21 @@ pub fn link_binary(sess: Session,
     // understand how to unwind our __morestack frame, so we have to turn it
     // off. This has impacted some other projects like GHC.
     if sess.targ_cfg.os == session::os_macos {
-        cc_args.push(~"-Wl,-no_compact_unwind");
+        args.push(~"-Wl,-no_compact_unwind");
     }
 
     // Stack growth requires statically linking a __morestack function
-    cc_args.push(~"-lmorestack");
+    args.push(~"-lmorestack");
 
     // Always want the runtime linked in
-    cc_args.push(~"-lrustrt");
+    args.push(~"-lrustrt");
 
     // FIXME (#2397): At some point we want to rpath our guesses as to where
     // extern libraries might live, based on the addl_lib_search_paths
-    cc_args.push_all(rpath::get_rpath_flags(sess, &output));
+    args.push_all(rpath::get_rpath_flags(sess, &output));
 
-    debug!("%s link args: %s", cc_prog, str::connect(cc_args, ~" "));
-    // We run 'cc' here
-    let prog = run::program_output(cc_prog, cc_args);
-    if 0 != prog.status {
-        sess.err(fmt!("linking with `%s` failed with code %d",
-                      cc_prog, prog.status));
-        sess.note(fmt!("%s arguments: %s",
-                       cc_prog, str::connect(cc_args, ~" ")));
-        sess.note(prog.err + prog.out);
-        sess.abort_if_errors();
-    }
+    // Finally add all the linker arguments provided on the command line
+    args.push_all(sess.opts.linker_args);
 
-    // Clean up on Darwin
-    if sess.targ_cfg.os == session::os_macos {
-        run::run_program(~"dsymutil", ~[output.to_str()]);
-    }
-
-    // Remove the temporary object file if we aren't saving temps
-    if !sess.opts.save_temps {
-        if ! os::remove_file(obj_filename) {
-            sess.warn(fmt!("failed to delete object file `%s`",
-                           obj_filename.to_str()));
-        }
-    }
+    return args;
 }
-//
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
-//
diff --git a/src/librustc/back/mips.rs b/src/librustc/back/mips.rs
index 93c1879eb0f..b15306a56b0 100644
--- a/src/librustc/back/mips.rs
+++ b/src/librustc/back/mips.rs
@@ -72,14 +72,3 @@ pub fn get_target_strs(target_os: session::os) -> target_strs::t {
         cc_args: ~[]
     };
 }
-
-
-//
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
-//
diff --git a/src/librustc/back/rpath.rs b/src/librustc/back/rpath.rs
index fab19b68174..fceff55abf8 100644
--- a/src/librustc/back/rpath.rs
+++ b/src/librustc/back/rpath.rs
@@ -40,7 +40,7 @@ pub fn get_rpath_flags(sess: session::Session, out_filename: &Path)
     // where rustrt is and we know every rust program needs it
     let libs = vec::append_one(libs, get_sysroot_absolute_rt_lib(sess));
 
-    let rpaths = get_rpaths(os, &sysroot, output, libs,
+    let rpaths = get_rpaths(os, sysroot, output, libs,
                             sess.opts.target_triple);
     rpaths_to_flags(rpaths)
 }
diff --git a/src/librustc/back/upcall.rs b/src/librustc/back/upcall.rs
index 4cdd279e2fc..8fcc5234e8b 100644
--- a/src/librustc/back/upcall.rs
+++ b/src/librustc/back/upcall.rs
@@ -59,12 +59,3 @@ pub fn declare_upcalls(targ_cfg: @session::config,
             nothrow(dv(~"reset_stack_limit", ~[]))
     }
 }
-//
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
-//
diff --git a/src/librustc/back/x86.rs b/src/librustc/back/x86.rs
index 2cc812c3d41..759f5f63c9e 100644
--- a/src/librustc/back/x86.rs
+++ b/src/librustc/back/x86.rs
@@ -55,13 +55,3 @@ pub fn get_target_strs(target_os: session::os) -> target_strs::t {
         cc_args: ~[~"-m32"]
     };
 }
-
-//
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
-//
diff --git a/src/librustc/back/x86_64.rs b/src/librustc/back/x86_64.rs
index b68073974dc..ed6f1d28514 100644
--- a/src/librustc/back/x86_64.rs
+++ b/src/librustc/back/x86_64.rs
@@ -63,13 +63,3 @@ pub fn get_target_strs(target_os: session::os) -> target_strs::t {
         cc_args: ~[~"-m64"]
     };
 }
-
-//
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
-//
diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs
index 6ce62a1382d..5e8dab0f772 100644
--- a/src/librustc/driver/driver.rs
+++ b/src/librustc/driver/driver.rs
@@ -234,7 +234,6 @@ pub fn compile_rest(sess: Session,
     let rp_set = time(time_passes, ~"region parameterization inference", ||
         middle::region::determine_rp_in_crate(sess, ast_map, def_map, crate));
 
-
     let outputs = outputs.get();
 
     let (llmod, link_meta) = {
@@ -306,6 +305,11 @@ pub fn compile_rest(sess: Session,
 
     };
 
+    if (sess.opts.debugging_opts & session::print_link_args) != 0 {
+        io::println(str::connect(link::link_args(sess,
+            &outputs.obj_filename, &outputs.out_filename, link_meta), " "));
+    }
+
     // NB: Android hack
     if sess.targ_cfg.arch == abi::Arm &&
             (sess.opts.output_type == link::output_type_object ||
@@ -596,7 +600,7 @@ pub fn build_session_options(binary: @~str,
             link::output_type_bitcode
         } else { link::output_type_exe };
     let sysroot_opt = getopts::opt_maybe_str(matches, ~"sysroot");
-    let sysroot_opt = sysroot_opt.map(|m| Path(*m));
+    let sysroot_opt = sysroot_opt.map(|m| @Path(*m));
     let target_opt = getopts::opt_maybe_str(matches, ~"target");
     let target_feature_opt = getopts::opt_maybe_str(matches, ~"target-feature");
     let save_temps = getopts::opt_present(matches, ~"save-temps");
@@ -637,13 +641,21 @@ pub fn build_session_options(binary: @~str,
         Some(s) => s
     };
 
-    let addl_lib_search_paths =
-        getopts::opt_strs(matches, ~"L")
-        .map(|s| Path(*s));
+    let addl_lib_search_paths = getopts::opt_strs(matches, ~"L").map(|s| Path(*s));
+    let linker = getopts::opt_maybe_str(matches, ~"linker");
+    let linker_args = getopts::opt_strs(matches, ~"link-args").flat_map( |a| {
+        let mut args = ~[];
+        for str::each_split_char(*a, ' ') |arg| {
+            args.push(str::from_slice(arg));
+        }
+        args
+    });
+
     let cfg = parse_cfgspecs(getopts::opt_strs(matches, ~"cfg"), demitter);
     let test = opt_present(matches, ~"test");
     let android_cross_path = getopts::opt_maybe_str(
         matches, ~"android-cross-path");
+
     let sopts = @session::options {
         crate_type: crate_type,
         is_static: static,
@@ -656,6 +668,8 @@ pub fn build_session_options(binary: @~str,
         jit: jit,
         output_type: output_type,
         addl_lib_search_paths: addl_lib_search_paths,
+        linker: linker,
+        linker_args: linker_args,
         maybe_sysroot: sysroot_opt,
         target_triple: target,
         target_feature: target_feature,
@@ -729,62 +743,65 @@ pub fn parse_pretty(sess: Session, name: &str) -> pp_mode {
 // rustc command line options
 pub fn optgroups() -> ~[getopts::groups::OptGroup] {
  ~[
-  optflag(~"",  ~"bin", ~"Compile an executable crate (default)"),
-  optflag(~"c", ~"",    ~"Compile and assemble, but do not link"),
-  optmulti(~"", ~"cfg", ~"Configure the compilation
-                          environment", ~"SPEC"),
-  optflag(~"",  ~"emit-llvm",
-                        ~"Produce an LLVM bitcode file"),
-  optflag(~"h", ~"help",~"Display this message"),
-  optmulti(~"L", ~"",   ~"Add a directory to the library search path",
-                              ~"PATH"),
-  optflag(~"",  ~"lib", ~"Compile a library crate"),
-  optflag(~"",  ~"ls",  ~"List the symbols defined by a library crate"),
-  optflag(~"", ~"no-trans",
-                        ~"Run all passes except translation; no output"),
-  optflag(~"O", ~"",    ~"Equivalent to --opt-level=2"),
-  optopt(~"o", ~"",     ~"Write output to <filename>", ~"FILENAME"),
-  optopt(~"", ~"opt-level",
-                        ~"Optimize with possible levels 0-3", ~"LEVEL"),
-  optopt( ~"",  ~"out-dir",
-                        ~"Write output to compiler-chosen filename
-                          in <dir>", ~"DIR"),
-  optflag(~"", ~"parse-only",
-                        ~"Parse only; do not compile, assemble, or link"),
-  optflagopt(~"", ~"pretty",
-                        ~"Pretty-print the input instead of compiling;
+  optflag("",  "bin", "Compile an executable crate (default)"),
+  optflag("c", "",    "Compile and assemble, but do not link"),
+  optmulti("", "cfg", "Configure the compilation
+                          environment", "SPEC"),
+  optflag("",  "emit-llvm",
+                        "Produce an LLVM bitcode file"),
+  optflag("h", "help","Display this message"),
+  optmulti("L", "",   "Add a directory to the library search path",
+                              "PATH"),
+  optflag("",  "lib", "Compile a library crate"),
+  optopt("", "linker", "Program to use for linking instead of the default.", "LINKER"),
+  optmulti("",  "link-args", "FLAGS is a space-separated list of flags
+                            passed to the linker", "FLAGS"),
+  optflag("",  "ls",  "List the symbols defined by a library crate"),
+  optflag("", "no-trans",
+                        "Run all passes except translation; no output"),
+  optflag("O", "",    "Equivalent to --opt-level=2"),
+  optopt("o", "",     "Write output to <filename>", "FILENAME"),
+  optopt("", "opt-level",
+                        "Optimize with possible levels 0-3", "LEVEL"),
+  optopt( "",  "out-dir",
+                        "Write output to compiler-chosen filename
+                          in <dir>", "DIR"),
+  optflag("", "parse-only",
+                        "Parse only; do not compile, assemble, or link"),
+  optflagopt("", "pretty",
+                        "Pretty-print the input instead of compiling;
                           valid types are: normal (un-annotated source),
                           expanded (crates expanded),
                           typed (crates expanded, with type annotations),
                           or identified (fully parenthesized,
-                          AST nodes and blocks with IDs)", ~"TYPE"),
-  optflag(~"S", ~"",    ~"Compile only; do not assemble or link"),
-  optflag(~"", ~"save-temps",
-                        ~"Write intermediate files (.bc, .opt.bc, .o)
+                          AST nodes and blocks with IDs)", "TYPE"),
+  optflag("S", "",    "Compile only; do not assemble or link"),
+  optflag("", "save-temps",
+                        "Write intermediate files (.bc, .opt.bc, .o)
                           in addition to normal output"),
-  optopt(~"", ~"sysroot",
-                        ~"Override the system root", ~"PATH"),
-  optflag(~"", ~"test", ~"Build a test harness"),
-  optopt(~"", ~"target",
-                        ~"Target triple cpu-manufacturer-kernel[-os]
+  optopt("", "sysroot",
+                        "Override the system root", "PATH"),
+  optflag("", "test", "Build a test harness"),
+  optopt("", "target",
+                        "Target triple cpu-manufacturer-kernel[-os]
                           to compile for (see chapter 3.4 of http://www.sourceware.org/autobook/
-                          for detail)", ~"TRIPLE"),
-  optopt(~"", ~"target-feature",
-                        ~"Target specific attributes (llc -mattr=help
-                          for detail)", ~"FEATURE"),
-  optopt(~"", ~"android-cross-path",
-         ~"The path to the Android NDK", "PATH"),
-  optmulti(~"W", ~"warn",
-                        ~"Set lint warnings", ~"OPT"),
-  optmulti(~"A", ~"allow",
-                        ~"Set lint allowed", ~"OPT"),
-  optmulti(~"D", ~"deny",
-                        ~"Set lint denied", ~"OPT"),
-  optmulti(~"F", ~"forbid",
-                        ~"Set lint forbidden", ~"OPT"),
-  optmulti(~"Z", ~"",   ~"Set internal debugging options", "FLAG"),
-  optflag( ~"v", ~"version",
-                        ~"Print version info and exit"),
+                          for detail)", "TRIPLE"),
+  optopt("", "target-feature",
+                        "Target specific attributes (llc -mattr=help
+                          for detail)", "FEATURE"),
+  optopt("", "android-cross-path",
+         "The path to the Android NDK", "PATH"),
+  optmulti("W", "warn",
+                        "Set lint warnings", "OPT"),
+  optmulti("A", "allow",
+                        "Set lint allowed", "OPT"),
+  optmulti("D", "deny",
+                        "Set lint denied", "OPT"),
+  optmulti("F", "forbid",
+                        "Set lint forbidden", "OPT"),
+  optmulti("Z", "",   "Set internal debugging options", "FLAG"),
+  optflag( "v", "version",
+                        "Print version info and exit"),
  ]
 }
 
@@ -928,11 +945,3 @@ mod test {
         assert!((vec::len(test_items) == 1u));
     }
 }
-
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
diff --git a/src/librustc/driver/session.rs b/src/librustc/driver/session.rs
index 15067b785d9..3b9bbbb9f1c 100644
--- a/src/librustc/driver/session.rs
+++ b/src/librustc/driver/session.rs
@@ -63,6 +63,7 @@ pub static jit: uint = 1 << 19;
 pub static debug_info: uint = 1 << 20;
 pub static extra_debug_info: uint = 1 << 21;
 pub static static: uint = 1 << 22;
+pub static print_link_args: uint = 1 << 23;
 
 pub fn debugging_opts_map() -> ~[(~str, ~str, uint)] {
     ~[(~"verbose", ~"in general, enable more debug printouts", verbose),
@@ -90,6 +91,7 @@ pub fn debugging_opts_map() -> ~[(~str, ~str, uint)] {
      (~"no-opt", ~"do not optimize, even if -O is passed", no_opt),
      (~"no-monomorphic-collapse", ~"do not collapse template instantiations",
       no_monomorphic_collapse),
+     (~"print-link-args", ~"Print the arguments passed to the linker", print_link_args),
      (~"gc", ~"Garbage collect shared data (experimental)", gc),
      (~"jit", ~"Execute using JIT (experimental)", jit),
      (~"extra-debug-info", ~"Extra debugging info (experimental)",
@@ -122,7 +124,9 @@ pub struct options {
     jit: bool,
     output_type: back::link::output_type,
     addl_lib_search_paths: ~[Path],
-    maybe_sysroot: Option<Path>,
+    linker: Option<~str>,
+    linker_args: ~[~str],
+    maybe_sysroot: Option<@Path>,
     target_triple: ~str,
     target_feature: ~str,
     // User-specified cfg meta items. The compiler itself will add additional
@@ -172,20 +176,16 @@ pub struct Session_ {
 pub type Session = @Session_;
 
 pub impl Session_ {
-    fn span_fatal(@self, sp: span, msg: ~str) -> ! {
-        debug!("span_fatal invoked: %s", msg);
+    fn span_fatal(@self, sp: span, msg: &str) -> ! {
         self.span_diagnostic.span_fatal(sp, msg)
     }
-    fn fatal(@self, msg: ~str) -> ! {
-        debug!("fatal invoked: %s", msg);
+    fn fatal(@self, msg: &str) -> ! {
         self.span_diagnostic.handler().fatal(msg)
     }
-    fn span_err(@self, sp: span, msg: ~str) {
-        debug!("span_err invoked: %s", msg);
+    fn span_err(@self, sp: span, msg: &str) {
         self.span_diagnostic.span_err(sp, msg)
     }
-    fn err(@self, msg: ~str) {
-        debug!("err invoked: %s", msg);
+    fn err(@self, msg: &str) {
         self.span_diagnostic.handler().err(msg)
     }
     fn has_errors(@self) -> bool {
@@ -194,35 +194,31 @@ pub impl Session_ {
     fn abort_if_errors(@self) {
         self.span_diagnostic.handler().abort_if_errors()
     }
-    fn span_warn(@self, sp: span, msg: ~str) {
-        debug!("span_warn invoked: %s", msg);
+    fn span_warn(@self, sp: span, msg: &str) {
         self.span_diagnostic.span_warn(sp, msg)
     }
-    fn warn(@self, msg: ~str) {
-        debug!("warn invoked: %s", msg);
+    fn warn(@self, msg: &str) {
         self.span_diagnostic.handler().warn(msg)
     }
-    fn span_note(@self, sp: span, msg: ~str) {
-        debug!("span_note invoked: %s", msg);
+    fn span_note(@self, sp: span, msg: &str) {
         self.span_diagnostic.span_note(sp, msg)
     }
-    fn note(@self, msg: ~str) {
-        debug!("note invoked: %s", msg);
+    fn note(@self, msg: &str) {
         self.span_diagnostic.handler().note(msg)
     }
-    fn span_bug(@self, sp: span, msg: ~str) -> ! {
+    fn span_bug(@self, sp: span, msg: &str) -> ! {
         self.span_diagnostic.span_bug(sp, msg)
     }
-    fn bug(@self, msg: ~str) -> ! {
+    fn bug(@self, msg: &str) -> ! {
         self.span_diagnostic.handler().bug(msg)
     }
-    fn span_unimpl(@self, sp: span, msg: ~str) -> ! {
+    fn span_unimpl(@self, sp: span, msg: &str) -> ! {
         self.span_diagnostic.span_unimpl(sp, msg)
     }
-    fn unimpl(@self, msg: ~str) -> ! {
+    fn unimpl(@self, msg: &str) -> ! {
         self.span_diagnostic.handler().unimpl(msg)
     }
-    fn span_lint_level(@self, level: lint::level, sp: span, msg: ~str) {
+    fn span_lint_level(@self, level: lint::level, sp: span, msg: &str) {
         match level {
           lint::allow => { },
           lint::warn => self.span_warn(sp, msg),
@@ -235,7 +231,7 @@ pub impl Session_ {
                  expr_id: ast::node_id,
                  item_id: ast::node_id,
                  span: span,
-                 msg: ~str) {
+                 msg: &str) {
         let level = lint::get_lint_settings_level(
             self.lint_settings, lint_mode, expr_id, item_id);
         self.span_lint_level(level, span, msg);
@@ -307,6 +303,8 @@ pub fn basic_options() -> @options {
         jit: false,
         output_type: link::output_type_exe,
         addl_lib_search_paths: ~[],
+        linker: None,
+        linker_args: ~[],
         maybe_sysroot: None,
         target_triple: host_triple(),
         target_feature: ~"",
@@ -434,10 +432,3 @@ mod test {
         assert!(building_library(lib_crate, crate, true));
     }
 }
-
-// Local Variables:
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
diff --git a/src/librustc/front/config.rs b/src/librustc/front/config.rs
index 75ae8724d72..2246dd9d2f0 100644
--- a/src/librustc/front/config.rs
+++ b/src/librustc/front/config.rs
@@ -194,11 +194,3 @@ pub fn metas_in_cfg(cfg: ast::crate_cfg,
         })
     })
 }
-
-
-// Local Variables:
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
diff --git a/src/librustc/front/test.rs b/src/librustc/front/test.rs
index 22bce62336c..0646afa1262 100644
--- a/src/librustc/front/test.rs
+++ b/src/librustc/front/test.rs
@@ -142,7 +142,7 @@ fn fold_item(cx: @mut TestCtxt, i: @ast::item, fld: @fold::ast_fold)
     debug!("current path: %s",
            ast_util::path_name_i(copy cx.path, cx.sess.parse_sess.interner));
 
-    if is_test_fn(i) || is_bench_fn(i) {
+    if is_test_fn(cx, i) || is_bench_fn(i) {
         match i.node {
           ast::item_fn(_, purity, _, _, _) if purity == ast::unsafe_fn => {
             let sess = cx.sess;
@@ -170,7 +170,7 @@ fn fold_item(cx: @mut TestCtxt, i: @ast::item, fld: @fold::ast_fold)
     return res;
 }
 
-fn is_test_fn(i: @ast::item) -> bool {
+fn is_test_fn(cx: @mut TestCtxt, i: @ast::item) -> bool {
     let has_test_attr = !attr::find_attrs_by_name(i.attrs,
                                                   ~"test").is_empty();
 
@@ -189,6 +189,13 @@ fn is_test_fn(i: @ast::item) -> bool {
         }
     }
 
+    if has_test_attr && !has_test_signature(i) {
+        let sess = cx.sess;
+        sess.span_err(
+            i.span,
+            ~"functions used as tests must have signature fn() -> ()."
+        );
+    }
     return has_test_attr && has_test_signature(i);
 }
 
@@ -457,11 +464,3 @@ fn mk_test_desc_and_fn_rec(cx: &TestCtxt, test: &Test) -> @ast::expr {
     );
     e
 }
-
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
diff --git a/src/librustc/lib/llvm.rs b/src/librustc/lib/llvm.rs
index 31050448e75..fbb3380554d 100644
--- a/src/librustc/lib/llvm.rs
+++ b/src/librustc/lib/llvm.rs
@@ -2196,13 +2196,3 @@ pub fn mk_section_iter(llof: ObjectFileRef) -> SectionIter {
         }
     }
 }
-
-//
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
-//
diff --git a/src/librustc/metadata/common.rs b/src/librustc/metadata/common.rs
index 8e689f3147b..d2b71447f47 100644
--- a/src/librustc/metadata/common.rs
+++ b/src/librustc/metadata/common.rs
@@ -100,7 +100,6 @@ pub static tag_mod_impl_trait: uint = 0x47u;
   different tags.
  */
 pub static tag_item_impl_method: uint = 0x48u;
-pub static tag_item_dtor: uint = 0x49u;
 pub static tag_item_trait_method_self_ty: uint = 0x4b;
 pub static tag_item_trait_method_self_ty_region: uint = 0x4c;
 
@@ -170,4 +169,3 @@ pub struct LinkMeta {
     vers: @str,
     extras_hash: @str
 }
-
diff --git a/src/librustc/metadata/creader.rs b/src/librustc/metadata/creader.rs
index 0d0f0d7ab69..da7a2c15f30 100644
--- a/src/librustc/metadata/creader.rs
+++ b/src/librustc/metadata/creader.rs
@@ -328,11 +328,3 @@ fn resolve_crate_deps(e: @mut Env, cdata: @~[u8]) -> cstore::cnum_map {
     }
     return @mut cnum_map;
 }
-
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
diff --git a/src/librustc/metadata/csearch.rs b/src/librustc/metadata/csearch.rs
index 5626714260b..375989b0ebe 100644
--- a/src/librustc/metadata/csearch.rs
+++ b/src/librustc/metadata/csearch.rs
@@ -230,13 +230,6 @@ pub fn get_impl_method(cstore: @mut cstore::CStore,
     decoder::get_impl_method(cstore.intr, cdata, def.node, mname)
 }
 
-/* If def names a class with a dtor, return it. Otherwise, return none. */
-pub fn struct_dtor(cstore: @mut cstore::CStore, def: ast::def_id)
-    -> Option<ast::def_id> {
-    let cdata = cstore::get_crate_data(cstore, def.crate);
-    decoder::struct_dtor(cdata, def.node)
-}
-
 pub fn get_item_visibility(cstore: @mut cstore::CStore,
                            def_id: ast::def_id)
                         -> ast::visibility {
@@ -250,11 +243,3 @@ pub fn get_link_args_for_crate(cstore: @mut cstore::CStore,
     let cdata = cstore::get_crate_data(cstore, crate_num);
     decoder::get_link_args_for_crate(cdata)
 }
-
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
diff --git a/src/librustc/metadata/cstore.rs b/src/librustc/metadata/cstore.rs
index 05275a4c665..21815a9ed47 100644
--- a/src/librustc/metadata/cstore.rs
+++ b/src/librustc/metadata/cstore.rs
@@ -161,11 +161,3 @@ pub fn get_dep_hashes(cstore: &CStore) -> ~[~str] {
 
     sorted.map(|ch| /*bad*/copy *ch.hash)
 }
-
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs
index 1a94b57279c..1e6bb397068 100644
--- a/src/librustc/metadata/decoder.rs
+++ b/src/librustc/metadata/decoder.rs
@@ -274,7 +274,8 @@ fn item_ty_param_defs(item: ebml::Doc, tcx: ty::ctxt, cdata: cmd,
 
 fn item_ty_region_param(item: ebml::Doc) -> Option<ty::region_variance> {
     reader::maybe_get_doc(item, tag_region_param).map(|doc| {
-        Decodable::decode(&reader::Decoder(*doc))
+        let mut decoder = reader::Decoder(*doc);
+        Decodable::decode(&mut decoder)
     })
 }
 
@@ -445,22 +446,6 @@ pub fn get_impl_method(intr: @ident_interner, cdata: cmd, id: ast::node_id,
     found.get()
 }
 
-pub fn struct_dtor(cdata: cmd, id: ast::node_id) -> Option<ast::def_id> {
-    let items = reader::get_doc(reader::Doc(cdata.data), tag_items);
-    let mut found = None;
-    let cls_items = match maybe_find_item(id, items) {
-            Some(it) => it,
-            None     => fail!(fmt!("struct_dtor: class id not found \
-              when looking up dtor for %d", id))
-    };
-    for reader::tagged_docs(cls_items, tag_item_dtor) |doc| {
-         let doc1 = reader::get_doc(doc, tag_def_id);
-         let did = reader::with_doc_data(doc1, |d| parse_def_id(d));
-         found = Some(translate_def_id(cdata, did));
-    };
-    found
-}
-
 pub fn get_symbol(data: @~[u8], id: ast::node_id) -> ~str {
     return item_symbol(lookup_item(id, data));
 }
@@ -1192,11 +1177,3 @@ pub fn get_link_args_for_crate(cdata: cmd) -> ~[~str] {
     }
     result
 }
-
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs
index 6d7442b1ed5..c337317314f 100644
--- a/src/librustc/metadata/encoder.rs
+++ b/src/librustc/metadata/encoder.rs
@@ -43,7 +43,7 @@ use writer = std::ebml::writer;
 type abbrev_map = @mut HashMap<ty::t, tyencode::ty_abbrev>;
 
 pub type encode_inlined_item = @fn(ecx: @EncodeContext,
-                                   ebml_w: &writer::Encoder,
+                                   ebml_w: &mut writer::Encoder,
                                    path: &[ast_map::path_elt],
                                    ii: ast::inlined_item);
 
@@ -91,38 +91,42 @@ pub fn reachable(ecx: @EncodeContext, id: node_id) -> bool {
     ecx.reachable.contains(&id)
 }
 
-fn encode_name(ecx: @EncodeContext, ebml_w: &writer::Encoder, name: ident) {
+fn encode_name(ecx: @EncodeContext,
+               ebml_w: &mut writer::Encoder,
+               name: ident) {
     ebml_w.wr_tagged_str(tag_paths_data_name, *ecx.tcx.sess.str_of(name));
 }
 
-fn encode_impl_type_basename(ecx: @EncodeContext, ebml_w: &writer::Encoder,
+fn encode_impl_type_basename(ecx: @EncodeContext,
+                             ebml_w: &mut writer::Encoder,
                              name: ident) {
     ebml_w.wr_tagged_str(tag_item_impl_type_basename,
                          *ecx.tcx.sess.str_of(name));
 }
 
-pub fn encode_def_id(ebml_w: &writer::Encoder, id: def_id) {
+pub fn encode_def_id(ebml_w: &mut writer::Encoder, id: def_id) {
     ebml_w.wr_tagged_str(tag_def_id, def_to_str(id));
 }
 
-fn encode_region_param(ecx: @EncodeContext, ebml_w: &writer::Encoder,
+fn encode_region_param(ecx: @EncodeContext,
+                       ebml_w: &mut writer::Encoder,
                        it: @ast::item) {
     let opt_rp = ecx.tcx.region_paramd_items.find(&it.id);
     for opt_rp.each |rp| {
-        do ebml_w.wr_tag(tag_region_param) {
-            rp.encode(ebml_w);
-        }
+        ebml_w.start_tag(tag_region_param);
+        rp.encode(ebml_w);
+        ebml_w.end_tag();
     }
 }
 
-fn encode_mutability(ebml_w: &writer::Encoder, mt: struct_mutability) {
-    do ebml_w.wr_tag(tag_struct_mut) {
-        let val = match mt {
-          struct_immutable => 'a',
-          struct_mutable => 'm'
-        };
-        ebml_w.writer.write(&[val as u8]);
-    }
+fn encode_mutability(ebml_w: &mut writer::Encoder, mt: struct_mutability) {
+    ebml_w.start_tag(tag_struct_mut);
+    let val = match mt {
+      struct_immutable => 'a',
+      struct_mutable => 'm'
+    };
+    ebml_w.writer.write(&[val as u8]);
+    ebml_w.end_tag();
 }
 
 struct entry<T> {
@@ -130,8 +134,11 @@ struct entry<T> {
     pos: uint
 }
 
-fn add_to_index(ecx: @EncodeContext, ebml_w: &writer::Encoder, path: &[ident],
-                index: &mut ~[entry<~str>], name: ident) {
+fn add_to_index(ecx: @EncodeContext,
+                ebml_w: &mut writer::Encoder,
+                path: &[ident],
+                index: &mut ~[entry<~str>],
+                name: ident) {
     let mut full_path = ~[];
     full_path.push_all(path);
     full_path.push(name);
@@ -143,11 +150,10 @@ fn add_to_index(ecx: @EncodeContext, ebml_w: &writer::Encoder, path: &[ident],
         });
 }
 
-fn encode_trait_ref(ebml_w: &writer::Encoder,
+fn encode_trait_ref(ebml_w: &mut writer::Encoder,
                     ecx: @EncodeContext,
                     trait_ref: &ty::TraitRef,
-                    tag: uint)
-{
+                    tag: uint) {
     let ty_str_ctxt = @tyencode::ctxt {
         diag: ecx.diag,
         ds: def_to_str,
@@ -161,15 +167,17 @@ fn encode_trait_ref(ebml_w: &writer::Encoder,
 }
 
 // Item info table encoding
-fn encode_family(ebml_w: &writer::Encoder, c: char) {
+fn encode_family(ebml_w: &mut writer::Encoder, c: char) {
     ebml_w.start_tag(tag_items_data_item_family);
     ebml_w.writer.write(&[c as u8]);
     ebml_w.end_tag();
 }
 
-pub fn def_to_str(did: def_id) -> ~str { fmt!("%d:%d", did.crate, did.node) }
+pub fn def_to_str(did: def_id) -> ~str {
+    fmt!("%d:%d", did.crate, did.node)
+}
 
-fn encode_ty_type_param_defs(ebml_w: &writer::Encoder,
+fn encode_ty_type_param_defs(ebml_w: &mut writer::Encoder,
                              ecx: @EncodeContext,
                              params: @~[ty::TypeParameterDef],
                              tag: uint) {
@@ -186,7 +194,7 @@ fn encode_ty_type_param_defs(ebml_w: &writer::Encoder,
     }
 }
 
-fn encode_type_param_bounds(ebml_w: &writer::Encoder,
+fn encode_type_param_bounds(ebml_w: &mut writer::Encoder,
                             ecx: @EncodeContext,
                             params: &OptVec<TyParam>) {
     let ty_param_defs =
@@ -195,14 +203,15 @@ fn encode_type_param_bounds(ebml_w: &writer::Encoder,
                               tag_items_data_item_ty_param_bounds);
 }
 
-
-fn encode_variant_id(ebml_w: &writer::Encoder, vid: def_id) {
+fn encode_variant_id(ebml_w: &mut writer::Encoder, vid: def_id) {
     ebml_w.start_tag(tag_items_data_item_variant);
     ebml_w.writer.write(str::to_bytes(def_to_str(vid)));
     ebml_w.end_tag();
 }
 
-pub fn write_type(ecx: @EncodeContext, ebml_w: &writer::Encoder, typ: ty::t) {
+pub fn write_type(ecx: @EncodeContext,
+                  ebml_w: &mut writer::Encoder,
+                  typ: ty::t) {
     let ty_str_ctxt = @tyencode::ctxt {
         diag: ecx.diag,
         ds: def_to_str,
@@ -212,7 +221,8 @@ pub fn write_type(ecx: @EncodeContext, ebml_w: &writer::Encoder, typ: ty::t) {
     tyencode::enc_ty(ebml_w.writer, ty_str_ctxt, typ);
 }
 
-pub fn write_vstore(ecx: @EncodeContext, ebml_w: &writer::Encoder,
+pub fn write_vstore(ecx: @EncodeContext,
+                    ebml_w: &mut writer::Encoder,
                     vstore: ty::vstore) {
     let ty_str_ctxt = @tyencode::ctxt {
         diag: ecx.diag,
@@ -223,16 +233,17 @@ pub fn write_vstore(ecx: @EncodeContext, ebml_w: &writer::Encoder,
     tyencode::enc_vstore(ebml_w.writer, ty_str_ctxt, vstore);
 }
 
-fn encode_type(ecx: @EncodeContext, ebml_w: &writer::Encoder, typ: ty::t) {
+fn encode_type(ecx: @EncodeContext,
+               ebml_w: &mut writer::Encoder,
+               typ: ty::t) {
     ebml_w.start_tag(tag_items_data_item_type);
     write_type(ecx, ebml_w, typ);
     ebml_w.end_tag();
 }
 
 fn encode_transformed_self_ty(ecx: @EncodeContext,
-                              ebml_w: &writer::Encoder,
-                              opt_typ: Option<ty::t>)
-{
+                              ebml_w: &mut writer::Encoder,
+                              opt_typ: Option<ty::t>) {
     for opt_typ.each |&typ| {
         ebml_w.start_tag(tag_item_method_transformed_self_ty);
         write_type(ecx, ebml_w, typ);
@@ -241,9 +252,8 @@ fn encode_transformed_self_ty(ecx: @EncodeContext,
 }
 
 fn encode_method_fty(ecx: @EncodeContext,
-                     ebml_w: &writer::Encoder,
-                     typ: &ty::BareFnTy)
-{
+                     ebml_w: &mut writer::Encoder,
+                     typ: &ty::BareFnTy) {
     ebml_w.start_tag(tag_item_method_fty);
 
     let ty_str_ctxt = @tyencode::ctxt {
@@ -257,7 +267,9 @@ fn encode_method_fty(ecx: @EncodeContext,
     ebml_w.end_tag();
 }
 
-fn encode_symbol(ecx: @EncodeContext, ebml_w: &writer::Encoder, id: node_id) {
+fn encode_symbol(ecx: @EncodeContext,
+                 ebml_w: &mut writer::Encoder,
+                 id: node_id) {
     ebml_w.start_tag(tag_items_data_item_symbol);
     match ecx.item_symbols.find(&id) {
         Some(x) => {
@@ -272,28 +284,32 @@ fn encode_symbol(ecx: @EncodeContext, ebml_w: &writer::Encoder, id: node_id) {
     ebml_w.end_tag();
 }
 
-fn encode_discriminant(ecx: @EncodeContext, ebml_w: &writer::Encoder,
+fn encode_discriminant(ecx: @EncodeContext,
+                       ebml_w: &mut writer::Encoder,
                        id: node_id) {
     ebml_w.start_tag(tag_items_data_item_symbol);
     ebml_w.writer.write(str::to_bytes(*ecx.discrim_symbols.get_copy(&id)));
     ebml_w.end_tag();
 }
 
-fn encode_disr_val(_ecx: @EncodeContext, ebml_w: &writer::Encoder,
+fn encode_disr_val(_: @EncodeContext,
+                   ebml_w: &mut writer::Encoder,
                    disr_val: int) {
     ebml_w.start_tag(tag_disr_val);
     ebml_w.writer.write(str::to_bytes(int::to_str(disr_val)));
     ebml_w.end_tag();
 }
 
-fn encode_parent_item(ebml_w: &writer::Encoder, id: def_id) {
+fn encode_parent_item(ebml_w: &mut writer::Encoder, id: def_id) {
     ebml_w.start_tag(tag_items_data_parent_item);
     ebml_w.writer.write(str::to_bytes(def_to_str(id)));
     ebml_w.end_tag();
 }
 
-fn encode_enum_variant_info(ecx: @EncodeContext, ebml_w: &writer::Encoder,
-                            id: node_id, variants: &[variant],
+fn encode_enum_variant_info(ecx: @EncodeContext,
+                            ebml_w: &mut writer::Encoder,
+                            id: node_id,
+                            variants: &[variant],
                             path: &[ast_map::path_elt],
                             index: @mut ~[entry<int>],
                             generics: &ast::Generics) {
@@ -333,9 +349,12 @@ fn encode_enum_variant_info(ecx: @EncodeContext, ebml_w: &writer::Encoder,
     }
 }
 
-fn encode_path(ecx: @EncodeContext, ebml_w: &writer::Encoder,
-               path: &[ast_map::path_elt], name: ast_map::path_elt) {
-    fn encode_path_elt(ecx: @EncodeContext, ebml_w: &writer::Encoder,
+fn encode_path(ecx: @EncodeContext,
+               ebml_w: &mut writer::Encoder,
+               path: &[ast_map::path_elt],
+               name: ast_map::path_elt) {
+    fn encode_path_elt(ecx: @EncodeContext,
+                       ebml_w: &mut writer::Encoder,
                        elt: ast_map::path_elt) {
         let (tag, name) = match elt {
           ast_map::path_mod(name) => (tag_path_elt_mod, name),
@@ -345,17 +364,20 @@ fn encode_path(ecx: @EncodeContext, ebml_w: &writer::Encoder,
         ebml_w.wr_tagged_str(tag, *ecx.tcx.sess.str_of(name));
     }
 
-    do ebml_w.wr_tag(tag_path) {
-        ebml_w.wr_tagged_u32(tag_path_len, (path.len() + 1) as u32);
-        for path.each |pe| {
-            encode_path_elt(ecx, ebml_w, *pe);
-        }
-        encode_path_elt(ecx, ebml_w, name);
+    ebml_w.start_tag(tag_path);
+    ebml_w.wr_tagged_u32(tag_path_len, (path.len() + 1) as u32);
+    for path.each |pe| {
+        encode_path_elt(ecx, ebml_w, *pe);
     }
+    encode_path_elt(ecx, ebml_w, name);
+    ebml_w.end_tag();
 }
 
-fn encode_info_for_mod(ecx: @EncodeContext, ebml_w: &writer::Encoder,
-                       md: &_mod, id: node_id, path: &[ast_map::path_elt],
+fn encode_info_for_mod(ecx: @EncodeContext,
+                       ebml_w: &mut writer::Encoder,
+                       md: &_mod,
+                       id: node_id,
+                       path: &[ast_map::path_elt],
                        name: ident) {
     ebml_w.start_tag(tag_items_data_item);
     encode_def_id(ebml_w, local_def(id));
@@ -412,7 +434,7 @@ fn encode_info_for_mod(ecx: @EncodeContext, ebml_w: &writer::Encoder,
     ebml_w.end_tag();
 }
 
-fn encode_struct_field_family(ebml_w: &writer::Encoder,
+fn encode_struct_field_family(ebml_w: &mut writer::Encoder,
                               visibility: visibility) {
     encode_family(ebml_w, match visibility {
         public => 'g',
@@ -421,7 +443,7 @@ fn encode_struct_field_family(ebml_w: &writer::Encoder,
     });
 }
 
-fn encode_visibility(ebml_w: &writer::Encoder, visibility: visibility) {
+fn encode_visibility(ebml_w: &mut writer::Encoder, visibility: visibility) {
     ebml_w.start_tag(tag_items_data_item_visibility);
     let ch = match visibility {
         public => 'y',
@@ -432,7 +454,7 @@ fn encode_visibility(ebml_w: &writer::Encoder, visibility: visibility) {
     ebml_w.end_tag();
 }
 
-fn encode_self_type(ebml_w: &writer::Encoder, self_type: ast::self_ty_) {
+fn encode_self_type(ebml_w: &mut writer::Encoder, self_type: ast::self_ty_) {
     ebml_w.start_tag(tag_item_trait_method_self_ty);
 
     // Encode the base self type.
@@ -476,17 +498,19 @@ fn encode_self_type(ebml_w: &writer::Encoder, self_type: ast::self_ty_) {
     }
 }
 
-fn encode_method_sort(ebml_w: &writer::Encoder, sort: char) {
+fn encode_method_sort(ebml_w: &mut writer::Encoder, sort: char) {
     ebml_w.start_tag(tag_item_trait_method_sort);
     ebml_w.writer.write(&[ sort as u8 ]);
     ebml_w.end_tag();
 }
 
 /* Returns an index of items in this class */
-fn encode_info_for_struct(ecx: @EncodeContext, ebml_w: &writer::Encoder,
-                         path: &[ast_map::path_elt],
-                         fields: &[@struct_field],
-                         global_index: @mut~[entry<int>]) -> ~[entry<int>] {
+fn encode_info_for_struct(ecx: @EncodeContext,
+                          ebml_w: &mut writer::Encoder,
+                          path: &[ast_map::path_elt],
+                          fields: &[@struct_field],
+                          global_index: @mut ~[entry<int>])
+                          -> ~[entry<int>] {
     /* Each class has its own index, since different classes
        may have fields with the same name */
     let index = @mut ~[];
@@ -522,7 +546,7 @@ fn encode_info_for_struct(ecx: @EncodeContext, ebml_w: &writer::Encoder,
 
 // This is for encoding info for ctors and dtors
 fn encode_info_for_ctor(ecx: @EncodeContext,
-                        ebml_w: &writer::Encoder,
+                        ebml_w: &mut writer::Encoder,
                         id: node_id,
                         ident: ident,
                         path: &[ast_map::path_elt],
@@ -551,7 +575,7 @@ fn encode_info_for_ctor(ecx: @EncodeContext,
 }
 
 fn encode_info_for_struct_ctor(ecx: @EncodeContext,
-                               ebml_w: &writer::Encoder,
+                               ebml_w: &mut writer::Encoder,
                                path: &[ast_map::path_elt],
                                name: ast::ident,
                                ctor_id: node_id,
@@ -573,9 +597,8 @@ fn encode_info_for_struct_ctor(ecx: @EncodeContext,
 }
 
 fn encode_method_ty_fields(ecx: @EncodeContext,
-                           ebml_w: &writer::Encoder,
-                           method_ty: &ty::method)
-{
+                           ebml_w: &mut writer::Encoder,
+                           method_ty: &ty::method) {
     encode_def_id(ebml_w, method_ty.def_id);
     encode_name(ecx, ebml_w, method_ty.ident);
     encode_ty_type_param_defs(ebml_w, ecx,
@@ -588,7 +611,7 @@ fn encode_method_ty_fields(ecx: @EncodeContext,
 }
 
 fn encode_info_for_method(ecx: @EncodeContext,
-                          ebml_w: &writer::Encoder,
+                          ebml_w: &mut writer::Encoder,
                           impl_path: &[ast_map::path_elt],
                           should_inline: bool,
                           parent_id: node_id,
@@ -658,11 +681,11 @@ fn should_inline(attrs: &[attribute]) -> bool {
     }
 }
 
-
-fn encode_info_for_item(ecx: @EncodeContext, ebml_w: &writer::Encoder,
-                        item: @item, index: @mut ~[entry<int>],
+fn encode_info_for_item(ecx: @EncodeContext,
+                        ebml_w: &mut writer::Encoder,
+                        item: @item,
+                        index: @mut ~[entry<int>],
                         path: &[ast_map::path_elt]) {
-
     let tcx = ecx.tcx;
     let must_write =
         match item.node {
@@ -737,19 +760,21 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: &writer::Encoder,
       }
       item_enum(ref enum_definition, ref generics) => {
         add_to_index();
-        do ebml_w.wr_tag(tag_items_data_item) {
-            encode_def_id(ebml_w, local_def(item.id));
-            encode_family(ebml_w, 't');
-            encode_type_param_bounds(ebml_w, ecx, &generics.ty_params);
-            encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id));
-            encode_name(ecx, ebml_w, item.ident);
-            for (*enum_definition).variants.each |v| {
-                encode_variant_id(ebml_w, local_def(v.node.id));
-            }
-            (ecx.encode_inlined_item)(ecx, ebml_w, path, ii_item(item));
-            encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident));
-            encode_region_param(ecx, ebml_w, item);
+
+        ebml_w.start_tag(tag_items_data_item);
+        encode_def_id(ebml_w, local_def(item.id));
+        encode_family(ebml_w, 't');
+        encode_type_param_bounds(ebml_w, ecx, &generics.ty_params);
+        encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id));
+        encode_name(ecx, ebml_w, item.ident);
+        for (*enum_definition).variants.each |v| {
+            encode_variant_id(ebml_w, local_def(v.node.id));
         }
+        (ecx.encode_inlined_item)(ecx, ebml_w, path, ii_item(item));
+        encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident));
+        encode_region_param(ecx, ebml_w, item);
+        ebml_w.end_tag();
+
         encode_enum_variant_info(ecx,
                                  ebml_w,
                                  item.id,
@@ -765,26 +790,6 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: &writer::Encoder,
            class itself */
         let idx = encode_info_for_struct(ecx, ebml_w, path,
                                          struct_def.fields, index);
-        /* Encode the dtor */
-        for struct_def.dtor.each |dtor| {
-            index.push(entry {val: dtor.node.id, pos: ebml_w.writer.tell()});
-          encode_info_for_ctor(ecx,
-                               ebml_w,
-                               dtor.node.id,
-                               ecx.tcx.sess.ident_of(
-                                   *ecx.tcx.sess.str_of(item.ident) +
-                                   ~"_dtor"),
-                               path,
-                               if generics.ty_params.len() > 0u {
-                                   Some(ii_dtor(copy *dtor,
-                                                item.ident,
-                                                copy *generics,
-                                                local_def(item.id))) }
-                               else {
-                                   None
-                               },
-                               generics);
-        }
 
         /* Index the class*/
         add_to_index();
@@ -816,13 +821,6 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: &writer::Encoder,
         encode_name(ecx, ebml_w, item.ident);
         encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident));
         encode_region_param(ecx, ebml_w, item);
-        /* Encode the dtor */
-        /* Encode id for dtor */
-        for struct_def.dtor.each |dtor| {
-            do ebml_w.wr_tag(tag_item_dtor) {
-                encode_def_id(ebml_w, local_def(dtor.node.id));
-            }
-        };
 
         /* Encode def_ids for each field and method
          for methods, write all the stuff get_trait_method
@@ -988,7 +986,7 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: &writer::Encoder,
 }
 
 fn encode_info_for_foreign_item(ecx: @EncodeContext,
-                                ebml_w: &writer::Encoder,
+                                ebml_w: &mut writer::Encoder,
                                 nitem: @foreign_item,
                                 index: @mut ~[entry<int>],
                                 path: ast_map::path,
@@ -1021,8 +1019,10 @@ fn encode_info_for_foreign_item(ecx: @EncodeContext,
     ebml_w.end_tag();
 }
 
-fn encode_info_for_items(ecx: @EncodeContext, ebml_w: &writer::Encoder,
-                         crate: &crate) -> ~[entry<int>] {
+fn encode_info_for_items(ecx: @EncodeContext,
+                         ebml_w: &mut writer::Encoder,
+                         crate: &crate)
+                         -> ~[entry<int>] {
     let index = @mut ~[];
     ebml_w.start_tag(tag_items_data);
     index.push(entry { val: crate_node_id, pos: ebml_w.writer.tell() });
@@ -1037,8 +1037,8 @@ fn encode_info_for_items(ecx: @EncodeContext, ebml_w: &writer::Encoder,
                 visit::visit_item(i, cx, v);
                 match ecx.tcx.items.get_copy(&i.id) {
                     ast_map::node_item(_, pt) => {
-                        encode_info_for_item(ecx, &ebml_w, i,
-                                             index, *pt);
+                        let mut ebml_w = copy ebml_w;
+                        encode_info_for_item(ecx, &mut ebml_w, i, index, *pt);
                     }
                     _ => fail!(~"bad item")
                 }
@@ -1050,8 +1050,12 @@ fn encode_info_for_items(ecx: @EncodeContext, ebml_w: &writer::Encoder,
                 visit::visit_foreign_item(ni, cx, v);
                 match ecx.tcx.items.get_copy(&ni.id) {
                     ast_map::node_foreign_item(_, abi, _, pt) => {
-                        encode_info_for_foreign_item(ecx, &ebml_w, ni,
-                                                     index, /*bad*/copy *pt,
+                        let mut ebml_w = copy ebml_w;
+                        encode_info_for_foreign_item(ecx,
+                                                     &mut ebml_w,
+                                                     ni,
+                                                     index,
+                                                     /*bad*/copy *pt,
                                                      abi);
                     }
                     // case for separate item and foreign-item tables
@@ -1084,7 +1088,8 @@ fn create_index<T:Copy + Hash + IterBytes>(index: ~[entry<T>]) ->
     return buckets_frozen;
 }
 
-fn encode_index<T>(ebml_w: &writer::Encoder, buckets: ~[@~[entry<T>]],
+fn encode_index<T>(ebml_w: &mut writer::Encoder,
+                   buckets: ~[@~[entry<T>]],
                    write_fn: &fn(@io::Writer, &T)) {
     let writer = ebml_w.writer;
     ebml_w.start_tag(tag_index);
@@ -1112,14 +1117,16 @@ fn encode_index<T>(ebml_w: &writer::Encoder, buckets: ~[@~[entry<T>]],
     ebml_w.end_tag();
 }
 
-fn write_str(writer: @io::Writer, s: ~str) { writer.write_str(s); }
+fn write_str(writer: @io::Writer, s: ~str) {
+    writer.write_str(s);
+}
 
 fn write_int(writer: @io::Writer, &n: &int) {
     assert!(n < 0x7fff_ffff);
     writer.write_be_u32(n as u32);
 }
 
-fn encode_meta_item(ebml_w: &writer::Encoder, mi: @meta_item) {
+fn encode_meta_item(ebml_w: &mut writer::Encoder, mi: @meta_item) {
     match mi.node {
       meta_word(name) => {
         ebml_w.start_tag(tag_meta_item_word);
@@ -1156,7 +1163,7 @@ fn encode_meta_item(ebml_w: &writer::Encoder, mi: @meta_item) {
     }
 }
 
-fn encode_attributes(ebml_w: &writer::Encoder, attrs: &[attribute]) {
+fn encode_attributes(ebml_w: &mut writer::Encoder, attrs: &[attribute]) {
     ebml_w.start_tag(tag_attributes);
     for attrs.each |attr| {
         ebml_w.start_tag(tag_attribute);
@@ -1221,7 +1228,7 @@ fn synthesize_crate_attrs(ecx: @EncodeContext,
 }
 
 fn encode_crate_deps(ecx: @EncodeContext,
-                     ebml_w: &writer::Encoder,
+                     ebml_w: &mut writer::Encoder,
                      cstore: @mut cstore::CStore) {
     fn get_ordered_deps(ecx: @EncodeContext, cstore: @mut cstore::CStore)
                      -> ~[decoder::crate_dep] {
@@ -1262,7 +1269,7 @@ fn encode_crate_deps(ecx: @EncodeContext,
     ebml_w.end_tag();
 }
 
-fn encode_lang_items(ecx: @EncodeContext, ebml_w: &writer::Encoder) {
+fn encode_lang_items(ecx: @EncodeContext, ebml_w: &mut writer::Encoder) {
     ebml_w.start_tag(tag_lang_items);
 
     for ecx.tcx.lang_items.each_item |def_id, i| {
@@ -1286,8 +1293,7 @@ fn encode_lang_items(ecx: @EncodeContext, ebml_w: &writer::Encoder) {
     ebml_w.end_tag();   // tag_lang_items
 }
 
-fn encode_link_args(ecx: @EncodeContext,
-                    ebml_w: &writer::Encoder) {
+fn encode_link_args(ecx: @EncodeContext, ebml_w: &mut writer::Encoder) {
     ebml_w.start_tag(tag_link_args);
 
     let link_args = cstore::get_used_link_args(ecx.cstore);
@@ -1300,7 +1306,8 @@ fn encode_link_args(ecx: @EncodeContext,
     ebml_w.end_tag();
 }
 
-fn encode_crate_dep(ecx: @EncodeContext, ebml_w: &writer::Encoder,
+fn encode_crate_dep(ecx: @EncodeContext,
+                    ebml_w: &mut writer::Encoder,
                     dep: decoder::crate_dep) {
     ebml_w.start_tag(tag_crate_dep);
     ebml_w.start_tag(tag_crate_dep_name);
@@ -1315,7 +1322,7 @@ fn encode_crate_dep(ecx: @EncodeContext, ebml_w: &writer::Encoder,
     ebml_w.end_tag();
 }
 
-fn encode_hash(ebml_w: &writer::Encoder, hash: &str) {
+fn encode_hash(ebml_w: &mut writer::Encoder, hash: &str) {
     ebml_w.start_tag(tag_crate_hash);
     ebml_w.writer.write(str::to_bytes(hash));
     ebml_w.end_tag();
@@ -1360,38 +1367,38 @@ pub fn encode_metadata(parms: EncodeParams, crate: &crate) -> ~[u8] {
         type_abbrevs: @mut HashMap::new()
      };
 
-    let ebml_w = writer::Encoder(wr as @io::Writer);
+    let mut ebml_w = writer::Encoder(wr as @io::Writer);
 
-    encode_hash(&ebml_w, ecx.link_meta.extras_hash);
+    encode_hash(&mut ebml_w, ecx.link_meta.extras_hash);
 
     let mut i = wr.pos;
     let crate_attrs = synthesize_crate_attrs(ecx, crate);
-    encode_attributes(&ebml_w, crate_attrs);
+    encode_attributes(&mut ebml_w, crate_attrs);
     ecx.stats.attr_bytes = wr.pos - i;
 
     i = wr.pos;
-    encode_crate_deps(ecx, &ebml_w, ecx.cstore);
+    encode_crate_deps(ecx, &mut ebml_w, ecx.cstore);
     ecx.stats.dep_bytes = wr.pos - i;
 
     // Encode the language items.
     i = wr.pos;
-    encode_lang_items(ecx, &ebml_w);
+    encode_lang_items(ecx, &mut ebml_w);
     ecx.stats.lang_item_bytes = wr.pos - i;
 
     // Encode the link args.
     i = wr.pos;
-    encode_link_args(ecx, &ebml_w);
+    encode_link_args(ecx, &mut ebml_w);
     ecx.stats.link_args_bytes = wr.pos - i;
 
     // Encode and index the items.
     ebml_w.start_tag(tag_items);
     i = wr.pos;
-    let items_index = encode_info_for_items(ecx, &ebml_w, crate);
+    let items_index = encode_info_for_items(ecx, &mut ebml_w, crate);
     ecx.stats.item_bytes = wr.pos - i;
 
     i = wr.pos;
     let items_buckets = create_index(items_index);
-    encode_index(&ebml_w, items_buckets, write_int);
+    encode_index(&mut ebml_w, items_buckets, write_int);
     ecx.stats.index_bytes = wr.pos - i;
     ebml_w.end_tag();
 
@@ -1447,12 +1454,3 @@ pub fn encoded_ty(tcx: ty::ctxt, t: ty::t) -> ~str {
         tyencode::enc_ty(wr, cx, t);
     }
 }
-
-
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
diff --git a/src/librustc/metadata/filesearch.rs b/src/librustc/metadata/filesearch.rs
index c88d5437c84..7547f7f763a 100644
--- a/src/librustc/metadata/filesearch.rs
+++ b/src/librustc/metadata/filesearch.rs
@@ -20,41 +20,48 @@ pub fn pick_file(file: Path, path: &Path) -> Option<Path> {
 }
 
 pub trait FileSearch {
-    fn sysroot(&self) -> Path;
-    fn lib_search_paths(&self) -> ~[Path];
+    fn sysroot(&self) -> @Path;
+    fn for_each_lib_search_path(&self, f: &fn(&Path) -> bool);
     fn get_target_lib_path(&self) -> Path;
     fn get_target_lib_file_path(&self, file: &Path) -> Path;
 }
 
-pub fn mk_filesearch(maybe_sysroot: &Option<Path>,
+pub fn mk_filesearch(maybe_sysroot: &Option<@Path>,
                      target_triple: &str,
                      addl_lib_search_paths: ~[Path])
                   -> @FileSearch {
     struct FileSearchImpl {
-        sysroot: Path,
+        sysroot: @Path,
         addl_lib_search_paths: ~[Path],
         target_triple: ~str
     }
     impl FileSearch for FileSearchImpl {
-        fn sysroot(&self) -> Path { /*bad*/copy self.sysroot }
-        fn lib_search_paths(&self) -> ~[Path] {
-            let mut paths = /*bad*/copy self.addl_lib_search_paths;
-
-            paths.push(
-                make_target_lib_path(&self.sysroot,
-                                     self.target_triple));
-            match get_rustpkg_lib_path_nearest() {
-              result::Ok(ref p) => paths.push((/*bad*/copy *p)),
-              result::Err(_) => ()
+        fn sysroot(&self) -> @Path { self.sysroot }
+        fn for_each_lib_search_path(&self, f: &fn(&Path) -> bool) {
+            debug!("filesearch: searching additional lib search paths");
+            // a little weird
+            self.addl_lib_search_paths.each(f);
+
+            debug!("filesearch: searching target lib path");
+            if !f(&make_target_lib_path(self.sysroot,
+                                        self.target_triple)) {
+                return;
             }
-            match get_rustpkg_lib_path() {
-              result::Ok(ref p) => paths.push((/*bad*/copy *p)),
-              result::Err(_) => ()
-            }
-            paths
+            debug!("filesearch: searching rustpkg lib path nearest");
+            if match get_rustpkg_lib_path_nearest() {
+                    result::Ok(ref p) => f(p),
+                    result::Err(_) => true
+                } {
+                    return;
+                }
+           debug!("filesearch: searching rustpkg lib path");
+           match get_rustpkg_lib_path() {
+              result::Ok(ref p) => f(p),
+              result::Err(_) => true
+           };
         }
         fn get_target_lib_path(&self) -> Path {
-            make_target_lib_path(&self.sysroot, self.target_triple)
+            make_target_lib_path(self.sysroot, self.target_triple)
         }
         fn get_target_lib_file_path(&self, file: &Path) -> Path {
             self.get_target_lib_path().push_rel(file)
@@ -72,7 +79,7 @@ pub fn mk_filesearch(maybe_sysroot: &Option<Path>,
 
 pub fn search<T:Copy>(filesearch: @FileSearch, pick: pick<T>) -> Option<T> {
     let mut rslt = None;
-    for filesearch.lib_search_paths().each |lib_search_path| {
+    for filesearch.for_each_lib_search_path() |lib_search_path| {
         debug!("searching %s", lib_search_path.to_str());
         for os::list_dir_path(lib_search_path).each |path| {
             debug!("testing %s", path.to_str());
@@ -108,10 +115,10 @@ fn get_or_default_sysroot() -> Path {
     }
 }
 
-fn get_sysroot(maybe_sysroot: &Option<Path>) -> Path {
+fn get_sysroot(maybe_sysroot: &Option<@Path>) -> @Path {
     match *maybe_sysroot {
-      option::Some(ref sr) => (/*bad*/copy *sr),
-      option::None => get_or_default_sysroot()
+      option::Some(sr) => sr,
+      option::None => @get_or_default_sysroot()
     }
 }
 
diff --git a/src/librustc/metadata/loader.rs b/src/librustc/metadata/loader.rs
index d2982e58038..193f6fc8f0a 100644
--- a/src/librustc/metadata/loader.rs
+++ b/src/librustc/metadata/loader.rs
@@ -196,7 +196,7 @@ fn get_metadata_section(os: os,
         while llvm::LLVMIsSectionIteratorAtEnd(of.llof, si.llsi) == False {
             let name_buf = llvm::LLVMGetSectionName(si.llsi);
             let name = unsafe { str::raw::from_c_str(name_buf) };
-            debug!("get_matadata_section: name %s", name);
+            debug!("get_metadata_section: name %s", name);
             if name == read_meta_section_name(os) {
                 let cbuf = llvm::LLVMGetSectionContents(si.llsi);
                 let csz = llvm::LLVMGetSectionSize(si.llsi) as uint;
diff --git a/src/librustc/metadata/mod.rs b/src/librustc/metadata/mod.rs
index 78d5be4d4ae..24007380fee 100644
--- a/src/librustc/metadata/mod.rs
+++ b/src/librustc/metadata/mod.rs
@@ -18,4 +18,3 @@ pub mod cstore;
 pub mod csearch;
 pub mod loader;
 pub mod filesearch;
-
diff --git a/src/librustc/metadata/tydecode.rs b/src/librustc/metadata/tydecode.rs
index 963afa08bfe..02acafbd980 100644
--- a/src/librustc/metadata/tydecode.rs
+++ b/src/librustc/metadata/tydecode.rs
@@ -570,13 +570,3 @@ fn parse_bounds(st: @mut PState, conv: conv_did) -> @~[ty::param_bound] {
     }
     @bounds
 }
-
-//
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
-//
diff --git a/src/librustc/metadata/tyencode.rs b/src/librustc/metadata/tyencode.rs
index fdba3ac4f00..c44a8e74130 100644
--- a/src/librustc/metadata/tyencode.rs
+++ b/src/librustc/metadata/tyencode.rs
@@ -418,13 +418,3 @@ pub fn enc_type_param_def(w: @io::Writer, cx: @ctxt, v: &ty::TypeParameterDef) {
     w.write_char('|');
     enc_bounds(w, cx, v.bounds);
 }
-
-//
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
-//
diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs
index fad1af749ea..f3eac7995e8 100644
--- a/src/librustc/middle/astencode.rs
+++ b/src/librustc/middle/astencode.rs
@@ -76,7 +76,7 @@ trait tr_intern {
 // Top-level methods.
 
 pub fn encode_inlined_item(ecx: @e::EncodeContext,
-                           ebml_w: &writer::Encoder,
+                           ebml_w: &mut writer::Encoder,
                            path: &[ast_map::path_elt],
                            ii: ast::inlined_item,
                            maps: Maps) {
@@ -86,11 +86,12 @@ pub fn encode_inlined_item(ecx: @e::EncodeContext,
            ebml_w.writer.tell());
 
     let id_range = ast_util::compute_id_range_for_inlined_item(&ii);
-    do ebml_w.wr_tag(c::tag_ast as uint) {
-        id_range.encode(ebml_w);
-        encode_ast(ebml_w, simplify_ast(&ii));
-        encode_side_tables_for_ii(ecx, maps, ebml_w, &ii);
-    }
+
+    ebml_w.start_tag(c::tag_ast as uint);
+    id_range.encode(ebml_w);
+    encode_ast(ebml_w, simplify_ast(&ii));
+    encode_side_tables_for_ii(ecx, maps, ebml_w, &ii);
+    ebml_w.end_tag();
 
     debug!("< Encoded inlined fn: %s::%s (%u)",
            ast_map::path_to_str(path, ecx.tcx.sess.parse_sess.interner),
@@ -114,8 +115,8 @@ pub fn decode_inlined_item(cdata: @cstore::crate_metadata,
       Some(ast_doc) => {
         debug!("> Decoding inlined fn: %s::?",
                ast_map::path_to_str(path, tcx.sess.parse_sess.interner));
-        let ast_dsr = &reader::Decoder(ast_doc);
-        let from_id_range = Decodable::decode(ast_dsr);
+        let mut ast_dsr = reader::Decoder(ast_doc);
+        let from_id_range = Decodable::decode(&mut ast_dsr);
         let to_id_range = reserve_id_range(dcx.tcx.sess, from_id_range);
         let xcx = @ExtendedDecodeContext {
             dcx: dcx,
@@ -232,22 +233,21 @@ impl tr for span {
 }
 
 trait def_id_encoder_helpers {
-    fn emit_def_id(&self, did: ast::def_id);
+    fn emit_def_id(&mut self, did: ast::def_id);
 }
 
 impl<S:serialize::Encoder> def_id_encoder_helpers for S {
-    fn emit_def_id(&self, did: ast::def_id) {
+    fn emit_def_id(&mut self, did: ast::def_id) {
         did.encode(self)
     }
 }
 
 trait def_id_decoder_helpers {
-    fn read_def_id(&self, xcx: @ExtendedDecodeContext) -> ast::def_id;
+    fn read_def_id(&mut self, xcx: @ExtendedDecodeContext) -> ast::def_id;
 }
 
 impl<D:serialize::Decoder> def_id_decoder_helpers for D {
-
-    fn read_def_id(&self, xcx: @ExtendedDecodeContext) -> ast::def_id {
+    fn read_def_id(&mut self, xcx: @ExtendedDecodeContext) -> ast::def_id {
         let did: ast::def_id = Decodable::decode(self);
         did.tr(xcx)
     }
@@ -268,10 +268,10 @@ impl<D:serialize::Decoder> def_id_decoder_helpers for D {
 // We also have to adjust the spans: for now we just insert a dummy span,
 // but eventually we should add entries to the local codemap as required.
 
-fn encode_ast(ebml_w: &writer::Encoder, item: ast::inlined_item) {
-    do ebml_w.wr_tag(c::tag_tree as uint) {
-        item.encode(ebml_w)
-    }
+fn encode_ast(ebml_w: &mut writer::Encoder, item: ast::inlined_item) {
+    ebml_w.start_tag(c::tag_tree as uint);
+    item.encode(ebml_w);
+    ebml_w.end_tag();
 }
 
 // Produces a simplified copy of the AST which does not include things
@@ -322,22 +322,13 @@ fn simplify_ast(ii: &ast::inlined_item) -> ast::inlined_item {
       ast::ii_foreign(i) => {
         ast::ii_foreign(fld.fold_foreign_item(i))
       }
-      ast::ii_dtor(ref dtor, nm, ref tps, parent_id) => {
-        let dtor_body = fld.fold_block(&dtor.node.body);
-        ast::ii_dtor(
-            codemap::spanned {
-                node: ast::struct_dtor_ { body: dtor_body,
-                                          .. /*bad*/copy (*dtor).node },
-                .. (/*bad*/copy *dtor) },
-            nm, /*bad*/copy *tps, parent_id)
-      }
     }
 }
 
 fn decode_ast(par_doc: ebml::Doc) -> ast::inlined_item {
     let chi_doc = par_doc.get(c::tag_tree as uint);
-    let d = &reader::Decoder(chi_doc);
-    Decodable::decode(d)
+    let mut d = reader::Decoder(chi_doc);
+    Decodable::decode(&mut d)
 }
 
 fn renumber_ast(xcx: @ExtendedDecodeContext, ii: ast::inlined_item)
@@ -358,36 +349,19 @@ fn renumber_ast(xcx: @ExtendedDecodeContext, ii: ast::inlined_item)
       ast::ii_foreign(i) => {
         ast::ii_foreign(fld.fold_foreign_item(i))
       }
-      ast::ii_dtor(ref dtor, nm, ref generics, parent_id) => {
-        let dtor_body = fld.fold_block(&dtor.node.body);
-        let dtor_attrs = fld.fold_attributes(/*bad*/copy (*dtor).node.attrs);
-        let new_generics = fold::fold_generics(generics, fld);
-        let dtor_id = fld.new_id((*dtor).node.id);
-        let new_parent = xcx.tr_def_id(parent_id);
-        let new_self = fld.new_id((*dtor).node.self_id);
-        ast::ii_dtor(
-            codemap::spanned {
-                node: ast::struct_dtor_ { id: dtor_id,
-                                          attrs: dtor_attrs,
-                                          self_id: new_self,
-                                          body: dtor_body },
-                .. (/*bad*/copy *dtor)
-            },
-            nm, new_generics, new_parent)
-      }
      }
 }
 
 // ______________________________________________________________________
 // Encoding and decoding of ast::def
 
-fn encode_def(ebml_w: &writer::Encoder, def: ast::def) {
+fn encode_def(ebml_w: &mut writer::Encoder, def: ast::def) {
     def.encode(ebml_w)
 }
 
 fn decode_def(xcx: @ExtendedDecodeContext, doc: ebml::Doc) -> ast::def {
-    let dsr = &reader::Decoder(doc);
-    let def: ast::def = Decodable::decode(dsr);
+    let mut dsr = reader::Decoder(doc);
+    let def: ast::def = Decodable::decode(&mut dsr);
     def.tr(xcx)
 }
 
@@ -488,18 +462,18 @@ impl tr for ty::bound_region {
 // ______________________________________________________________________
 // Encoding and decoding of freevar information
 
-fn encode_freevar_entry(ebml_w: &writer::Encoder, fv: @freevar_entry) {
+fn encode_freevar_entry(ebml_w: &mut writer::Encoder, fv: @freevar_entry) {
     (*fv).encode(ebml_w)
 }
 
 trait ebml_decoder_helper {
-    fn read_freevar_entry(&self, xcx: @ExtendedDecodeContext)
-                         -> freevar_entry;
+    fn read_freevar_entry(&mut self, xcx: @ExtendedDecodeContext)
+                          -> freevar_entry;
 }
 
 impl ebml_decoder_helper for reader::Decoder {
-    fn read_freevar_entry(&self, xcx: @ExtendedDecodeContext)
-                         -> freevar_entry {
+    fn read_freevar_entry(&mut self, xcx: @ExtendedDecodeContext)
+                          -> freevar_entry {
         let fv: freevar_entry = Decodable::decode(self);
         fv.tr(xcx)
     }
@@ -518,13 +492,13 @@ impl tr for freevar_entry {
 // Encoding and decoding of CaptureVar information
 
 trait capture_var_helper {
-    fn read_capture_var(&self, xcx: @ExtendedDecodeContext)
-                       -> moves::CaptureVar;
+    fn read_capture_var(&mut self, xcx: @ExtendedDecodeContext)
+                        -> moves::CaptureVar;
 }
 
 impl capture_var_helper for reader::Decoder {
-    fn read_capture_var(&self, xcx: @ExtendedDecodeContext)
-                       -> moves::CaptureVar {
+    fn read_capture_var(&mut self, xcx: @ExtendedDecodeContext)
+                        -> moves::CaptureVar {
         let cvar: moves::CaptureVar = Decodable::decode(self);
         cvar.tr(xcx)
     }
@@ -544,48 +518,50 @@ impl tr for moves::CaptureVar {
 // Encoding and decoding of method_map_entry
 
 trait read_method_map_entry_helper {
-    fn read_method_map_entry(&self, xcx: @ExtendedDecodeContext)
-                            -> method_map_entry;
+    fn read_method_map_entry(&mut self, xcx: @ExtendedDecodeContext)
+                             -> method_map_entry;
 }
 
 fn encode_method_map_entry(ecx: @e::EncodeContext,
-                              ebml_w: &writer::Encoder,
-                              mme: method_map_entry) {
-    do ebml_w.emit_struct("method_map_entry", 3) {
-        do ebml_w.emit_struct_field("self_arg", 0u) {
+                           ebml_w: &mut writer::Encoder,
+                           mme: method_map_entry) {
+    do ebml_w.emit_struct("method_map_entry", 3) |ebml_w| {
+        do ebml_w.emit_struct_field("self_arg", 0u) |ebml_w| {
             ebml_w.emit_arg(ecx, mme.self_arg);
         }
-        do ebml_w.emit_struct_field("explicit_self", 2u) {
+        do ebml_w.emit_struct_field("explicit_self", 2u) |ebml_w| {
             mme.explicit_self.encode(ebml_w);
         }
-        do ebml_w.emit_struct_field("origin", 1u) {
+        do ebml_w.emit_struct_field("origin", 1u) |ebml_w| {
             mme.origin.encode(ebml_w);
         }
-        do ebml_w.emit_struct_field("self_mode", 3) {
+        do ebml_w.emit_struct_field("self_mode", 3) |ebml_w| {
             mme.self_mode.encode(ebml_w);
         }
     }
 }
 
 impl read_method_map_entry_helper for reader::Decoder {
-    fn read_method_map_entry(&self, xcx: @ExtendedDecodeContext)
-        -> method_map_entry {
-        do self.read_struct("method_map_entry", 3) {
+    fn read_method_map_entry(&mut self, xcx: @ExtendedDecodeContext)
+                             -> method_map_entry {
+        do self.read_struct("method_map_entry", 3) |this| {
             method_map_entry {
-                self_arg: self.read_struct_field("self_arg", 0u, || {
-                    self.read_arg(xcx)
+                self_arg: this.read_struct_field("self_arg", 0, |this| {
+                    this.read_arg(xcx)
                 }),
-                explicit_self: self.read_struct_field("explicit_self", 2, || {
-                    let self_type: ast::self_ty_ = Decodable::decode(self);
+                explicit_self: this.read_struct_field("explicit_self",
+                                                      2,
+                                                      |this| {
+                    let self_type: ast::self_ty_ = Decodable::decode(this);
                     self_type
                 }),
-                origin: self.read_struct_field("origin", 1u, || {
+                origin: this.read_struct_field("origin", 1, |this| {
                     let method_origin: method_origin =
-                        Decodable::decode(self);
+                        Decodable::decode(this);
                     method_origin.tr(xcx)
                 }),
-                self_mode: self.read_struct_field("self_mode", 3, || {
-                    let self_mode: ty::SelfMode = Decodable::decode(self);
+                self_mode: this.read_struct_field("self_mode", 3, |this| {
+                    let self_mode: ty::SelfMode = Decodable::decode(this);
                     self_mode
                 }),
             }
@@ -624,88 +600,88 @@ impl tr for method_origin {
 // Encoding and decoding vtable_res
 
 fn encode_vtable_res(ecx: @e::EncodeContext,
-                     ebml_w: &writer::Encoder,
+                     ebml_w: &mut writer::Encoder,
                      dr: typeck::vtable_res) {
     // can't autogenerate this code because automatic code of
     // ty::t doesn't work, and there is no way (atm) to have
     // hand-written encoding routines combine with auto-generated
     // ones.  perhaps we should fix this.
-    do ebml_w.emit_from_vec(*dr) |vtable_origin| {
+    do ebml_w.emit_from_vec(*dr) |ebml_w, vtable_origin| {
         encode_vtable_origin(ecx, ebml_w, vtable_origin)
     }
 }
 
 fn encode_vtable_origin(ecx: @e::EncodeContext,
-                        ebml_w: &writer::Encoder,
+                        ebml_w: &mut writer::Encoder,
                         vtable_origin: &typeck::vtable_origin) {
-    do ebml_w.emit_enum(~"vtable_origin") {
+    do ebml_w.emit_enum(~"vtable_origin") |ebml_w| {
         match *vtable_origin {
           typeck::vtable_static(def_id, ref tys, vtable_res) => {
-            do ebml_w.emit_enum_variant(~"vtable_static", 0u, 3u) {
-                do ebml_w.emit_enum_variant_arg(0u) {
+            do ebml_w.emit_enum_variant(~"vtable_static", 0u, 3u) |ebml_w| {
+                do ebml_w.emit_enum_variant_arg(0u) |ebml_w| {
                     ebml_w.emit_def_id(def_id)
                 }
-                do ebml_w.emit_enum_variant_arg(1u) {
+                do ebml_w.emit_enum_variant_arg(1u) |ebml_w| {
                     ebml_w.emit_tys(ecx, /*bad*/copy *tys);
                 }
-                do ebml_w.emit_enum_variant_arg(2u) {
+                do ebml_w.emit_enum_variant_arg(2u) |ebml_w| {
                     encode_vtable_res(ecx, ebml_w, vtable_res);
                 }
             }
           }
           typeck::vtable_param(pn, bn) => {
-            do ebml_w.emit_enum_variant(~"vtable_param", 1u, 2u) {
-                do ebml_w.emit_enum_variant_arg(0u) {
+            do ebml_w.emit_enum_variant(~"vtable_param", 1u, 2u) |ebml_w| {
+                do ebml_w.emit_enum_variant_arg(0u) |ebml_w| {
                     ebml_w.emit_uint(pn);
                 }
-                do ebml_w.emit_enum_variant_arg(1u) {
+                do ebml_w.emit_enum_variant_arg(1u) |ebml_w| {
                     ebml_w.emit_uint(bn);
                 }
             }
           }
         }
     }
-
 }
 
 trait vtable_decoder_helpers {
-    fn read_vtable_res(&self, xcx: @ExtendedDecodeContext)
+    fn read_vtable_res(&mut self, xcx: @ExtendedDecodeContext)
                       -> typeck::vtable_res;
-    fn read_vtable_origin(&self, xcx: @ExtendedDecodeContext)
-        -> typeck::vtable_origin;
+    fn read_vtable_origin(&mut self, xcx: @ExtendedDecodeContext)
+                          -> typeck::vtable_origin;
 }
 
 impl vtable_decoder_helpers for reader::Decoder {
-    fn read_vtable_res(&self, xcx: @ExtendedDecodeContext)
+    fn read_vtable_res(&mut self, xcx: @ExtendedDecodeContext)
                       -> typeck::vtable_res {
-        @self.read_to_vec(|| self.read_vtable_origin(xcx) )
+        @self.read_to_vec(|this| this.read_vtable_origin(xcx))
     }
 
-    fn read_vtable_origin(&self, xcx: @ExtendedDecodeContext)
+    fn read_vtable_origin(&mut self, xcx: @ExtendedDecodeContext)
         -> typeck::vtable_origin {
-        do self.read_enum("vtable_origin") {
-            do self.read_enum_variant(["vtable_static", "vtable_param"]) |i| {
+        do self.read_enum("vtable_origin") |this| {
+            do this.read_enum_variant(["vtable_static", "vtable_param"])
+                    |this, i| {
                 match i {
                   0 => {
                     typeck::vtable_static(
-                        do self.read_enum_variant_arg(0u) {
-                            self.read_def_id(xcx)
+                        do this.read_enum_variant_arg(0u) |this| {
+                            this.read_def_id(xcx)
                         },
-                        do self.read_enum_variant_arg(1u) {
-                            self.read_tys(xcx)
+                        do this.read_enum_variant_arg(1u) |this| {
+                            this.read_tys(xcx)
                         },
-                        do self.read_enum_variant_arg(2u) {
-                            self.read_vtable_res(xcx)
+                        do this.read_enum_variant_arg(2u) |this| {
+                            this.read_vtable_res(xcx)
                         }
                     )
                   }
                   1 => {
                     typeck::vtable_param(
-                        do self.read_enum_variant_arg(0u) {
-                            self.read_uint()
+                        do this.read_enum_variant_arg(0u) |this| {
+                            this.read_uint()
                         },
-                        do self.read_enum_variant_arg(1u) {
-                            self.read_uint()
+                        do this.read_enum_variant_arg(1u) |this| {
+                            this.read_uint()
                         }
                     )
                   }
@@ -736,148 +712,154 @@ impl get_ty_str_ctxt for e::EncodeContext {
 }
 
 trait ebml_writer_helpers {
-    fn emit_arg(&self, ecx: @e::EncodeContext, arg: ty::arg);
-    fn emit_ty(&self, ecx: @e::EncodeContext, ty: ty::t);
-    fn emit_vstore(&self, ecx: @e::EncodeContext, vstore: ty::vstore);
-    fn emit_tys(&self, ecx: @e::EncodeContext, tys: &[ty::t]);
-    fn emit_type_param_def(&self,
+    fn emit_arg(&mut self, ecx: @e::EncodeContext, arg: ty::arg);
+    fn emit_ty(&mut self, ecx: @e::EncodeContext, ty: ty::t);
+    fn emit_vstore(&mut self, ecx: @e::EncodeContext, vstore: ty::vstore);
+    fn emit_tys(&mut self, ecx: @e::EncodeContext, tys: &[ty::t]);
+    fn emit_type_param_def(&mut self,
                            ecx: @e::EncodeContext,
                            type_param_def: &ty::TypeParameterDef);
-    fn emit_tpbt(&self, ecx: @e::EncodeContext,
+    fn emit_tpbt(&mut self,
+                 ecx: @e::EncodeContext,
                  tpbt: ty::ty_param_bounds_and_ty);
 }
 
 impl ebml_writer_helpers for writer::Encoder {
-    fn emit_ty(&self, ecx: @e::EncodeContext, ty: ty::t) {
-        do self.emit_opaque {
-            e::write_type(ecx, self, ty)
+    fn emit_ty(&mut self, ecx: @e::EncodeContext, ty: ty::t) {
+        do self.emit_opaque |this| {
+            e::write_type(ecx, this, ty)
         }
     }
 
-    fn emit_vstore(&self, ecx: @e::EncodeContext, vstore: ty::vstore) {
-        do self.emit_opaque {
-            e::write_vstore(ecx, self, vstore)
+    fn emit_vstore(&mut self, ecx: @e::EncodeContext, vstore: ty::vstore) {
+        do self.emit_opaque |this| {
+            e::write_vstore(ecx, this, vstore)
         }
     }
 
-    fn emit_arg(&self, ecx: @e::EncodeContext, arg: ty::arg) {
-        do self.emit_opaque {
-            tyencode::enc_arg(self.writer, ecx.ty_str_ctxt(), arg);
+    fn emit_arg(&mut self, ecx: @e::EncodeContext, arg: ty::arg) {
+        do self.emit_opaque |this| {
+            tyencode::enc_arg(this.writer, ecx.ty_str_ctxt(), arg);
         }
     }
 
-    fn emit_tys(&self, ecx: @e::EncodeContext, tys: &[ty::t]) {
-        do self.emit_from_vec(tys) |ty| {
-            self.emit_ty(ecx, *ty)
+    fn emit_tys(&mut self, ecx: @e::EncodeContext, tys: &[ty::t]) {
+        do self.emit_from_vec(tys) |this, ty| {
+            this.emit_ty(ecx, *ty)
         }
     }
 
-    fn emit_type_param_def(&self,
+    fn emit_type_param_def(&mut self,
                            ecx: @e::EncodeContext,
                            type_param_def: &ty::TypeParameterDef) {
-        do self.emit_opaque {
-            tyencode::enc_type_param_def(self.writer, ecx.ty_str_ctxt(),
+        do self.emit_opaque |this| {
+            tyencode::enc_type_param_def(this.writer,
+                                         ecx.ty_str_ctxt(),
                                          type_param_def)
         }
     }
 
-    fn emit_tpbt(&self, ecx: @e::EncodeContext,
+    fn emit_tpbt(&mut self,
+                 ecx: @e::EncodeContext,
                  tpbt: ty::ty_param_bounds_and_ty) {
-        do self.emit_struct("ty_param_bounds_and_ty", 2) {
-            do self.emit_struct_field("generics", 0) {
-                do self.emit_struct("Generics", 2) {
-                    do self.emit_struct_field("type_param_defs", 0) {
-                        do self.emit_from_vec(*tpbt.generics.type_param_defs)
-                            |type_param_def|
-                        {
-                            self.emit_type_param_def(ecx, type_param_def);
+        do self.emit_struct("ty_param_bounds_and_ty", 2) |this| {
+            do this.emit_struct_field(~"generics", 0) |this| {
+                do this.emit_struct("Generics", 2) |this| {
+                    do this.emit_struct_field(~"type_param_defs", 0) |this| {
+                        do this.emit_from_vec(*tpbt.generics.type_param_defs)
+                                |this, type_param_def| {
+                            this.emit_type_param_def(ecx, type_param_def);
                         }
                     }
-                    do self.emit_struct_field("region_param", 1) {
-                        tpbt.generics.region_param.encode(self);
+                    do this.emit_struct_field(~"region_param", 1) |this| {
+                        tpbt.generics.region_param.encode(this);
                     }
                 }
             }
-            do self.emit_struct_field("ty", 1) {
-                self.emit_ty(ecx, tpbt.ty);
+            do this.emit_struct_field(~"ty", 1) |this| {
+                this.emit_ty(ecx, tpbt.ty);
             }
         }
     }
 }
 
 trait write_tag_and_id {
-    fn tag(&self, tag_id: c::astencode_tag, f: &fn());
-    fn id(&self, id: ast::node_id);
+    fn tag(&mut self, tag_id: c::astencode_tag, f: &fn(&mut Self));
+    fn id(&mut self, id: ast::node_id);
 }
 
 impl write_tag_and_id for writer::Encoder {
-    fn tag(&self, tag_id: c::astencode_tag, f: &fn()) {
-        do self.wr_tag(tag_id as uint) { f() }
+    fn tag(&mut self,
+           tag_id: c::astencode_tag,
+           f: &fn(&mut writer::Encoder)) {
+        self.start_tag(tag_id as uint);
+        f(self);
+        self.end_tag();
     }
 
-    fn id(&self, id: ast::node_id) {
+    fn id(&mut self, id: ast::node_id) {
         self.wr_tagged_u64(c::tag_table_id as uint, id as u64)
     }
 }
 
 fn encode_side_tables_for_ii(ecx: @e::EncodeContext,
                              maps: Maps,
-                             ebml_w: &writer::Encoder,
+                             ebml_w: &mut writer::Encoder,
                              ii: &ast::inlined_item) {
-    do ebml_w.wr_tag(c::tag_table as uint) {
-        let ebml_w = copy *ebml_w;
-        ast_util::visit_ids_for_inlined_item(
-            ii,
-            |id: ast::node_id| {
-                // Note: this will cause a copy of ebml_w, which is bad as
-                // it has mut fields.  But I believe it's harmless since
-                // we generate balanced EBML.
-                /*let ebml_w = copy ebml_w;*/
-                encode_side_tables_for_id(ecx, maps, &ebml_w, id)
-            });
-    }
+    ebml_w.start_tag(c::tag_table as uint);
+    let new_ebml_w = copy *ebml_w;
+    ast_util::visit_ids_for_inlined_item(
+        ii,
+        |id: ast::node_id| {
+            // Note: this will cause a copy of ebml_w, which is bad as
+            // it is mutable. But I believe it's harmless since we generate
+            // balanced EBML.
+            let mut new_ebml_w = copy new_ebml_w;
+            encode_side_tables_for_id(ecx, maps, &mut new_ebml_w, id)
+        });
+    ebml_w.end_tag();
 }
 
 fn encode_side_tables_for_id(ecx: @e::EncodeContext,
                              maps: Maps,
-                             ebml_w: &writer::Encoder,
+                             ebml_w: &mut writer::Encoder,
                              id: ast::node_id) {
     let tcx = ecx.tcx;
 
     debug!("Encoding side tables for id %d", id);
 
     for tcx.def_map.find(&id).each |def| {
-        do ebml_w.tag(c::tag_table_def) {
+        do ebml_w.tag(c::tag_table_def) |ebml_w| {
             ebml_w.id(id);
-            do ebml_w.tag(c::tag_table_val) {
+            do ebml_w.tag(c::tag_table_val) |ebml_w| {
                 (*def).encode(ebml_w)
             }
         }
     }
 
     for tcx.node_types.find(&(id as uint)).each |&ty| {
-        do ebml_w.tag(c::tag_table_node_type) {
+        do ebml_w.tag(c::tag_table_node_type) |ebml_w| {
             ebml_w.id(id);
-            do ebml_w.tag(c::tag_table_val) {
+            do ebml_w.tag(c::tag_table_val) |ebml_w| {
                 ebml_w.emit_ty(ecx, *ty);
             }
         }
     }
 
     for tcx.node_type_substs.find(&id).each |tys| {
-        do ebml_w.tag(c::tag_table_node_type_subst) {
+        do ebml_w.tag(c::tag_table_node_type_subst) |ebml_w| {
             ebml_w.id(id);
-            do ebml_w.tag(c::tag_table_val) {
+            do ebml_w.tag(c::tag_table_val) |ebml_w| {
                 ebml_w.emit_tys(ecx, **tys)
             }
         }
     }
 
     for tcx.freevars.find(&id).each |&fv| {
-        do ebml_w.tag(c::tag_table_freevars) {
+        do ebml_w.tag(c::tag_table_freevars) |ebml_w| {
             ebml_w.id(id);
-            do ebml_w.tag(c::tag_table_val) {
-                do ebml_w.emit_from_vec(**fv) |fv_entry| {
+            do ebml_w.tag(c::tag_table_val) |ebml_w| {
+                do ebml_w.emit_from_vec(**fv) |ebml_w, fv_entry| {
                     encode_freevar_entry(ebml_w, *fv_entry)
                 }
             }
@@ -886,61 +868,61 @@ fn encode_side_tables_for_id(ecx: @e::EncodeContext,
 
     let lid = ast::def_id { crate: ast::local_crate, node: id };
     for tcx.tcache.find(&lid).each |&tpbt| {
-        do ebml_w.tag(c::tag_table_tcache) {
+        do ebml_w.tag(c::tag_table_tcache) |ebml_w| {
             ebml_w.id(id);
-            do ebml_w.tag(c::tag_table_val) {
+            do ebml_w.tag(c::tag_table_val) |ebml_w| {
                 ebml_w.emit_tpbt(ecx, *tpbt);
             }
         }
     }
 
     for tcx.ty_param_defs.find(&id).each |&type_param_def| {
-        do ebml_w.tag(c::tag_table_param_defs) {
+        do ebml_w.tag(c::tag_table_param_defs) |ebml_w| {
             ebml_w.id(id);
-            do ebml_w.tag(c::tag_table_val) {
+            do ebml_w.tag(c::tag_table_val) |ebml_w| {
                 ebml_w.emit_type_param_def(ecx, type_param_def)
             }
         }
     }
 
     for maps.method_map.find(&id).each |&mme| {
-        do ebml_w.tag(c::tag_table_method_map) {
+        do ebml_w.tag(c::tag_table_method_map) |ebml_w| {
             ebml_w.id(id);
-            do ebml_w.tag(c::tag_table_val) {
+            do ebml_w.tag(c::tag_table_val) |ebml_w| {
                 encode_method_map_entry(ecx, ebml_w, *mme)
             }
         }
     }
 
     for maps.vtable_map.find(&id).each |&dr| {
-        do ebml_w.tag(c::tag_table_vtable_map) {
+        do ebml_w.tag(c::tag_table_vtable_map) |ebml_w| {
             ebml_w.id(id);
-            do ebml_w.tag(c::tag_table_val) {
+            do ebml_w.tag(c::tag_table_val) |ebml_w| {
                 encode_vtable_res(ecx, ebml_w, *dr);
             }
         }
     }
 
     for tcx.adjustments.find(&id).each |adj| {
-        do ebml_w.tag(c::tag_table_adjustments) {
+        do ebml_w.tag(c::tag_table_adjustments) |ebml_w| {
             ebml_w.id(id);
-            do ebml_w.tag(c::tag_table_val) {
+            do ebml_w.tag(c::tag_table_val) |ebml_w| {
                 (**adj).encode(ebml_w)
             }
         }
     }
 
     if maps.moves_map.contains(&id) {
-        do ebml_w.tag(c::tag_table_moves_map) {
+        do ebml_w.tag(c::tag_table_moves_map) |ebml_w| {
             ebml_w.id(id);
         }
     }
 
     for maps.capture_map.find(&id).each |&cap_vars| {
-        do ebml_w.tag(c::tag_table_capture_map) {
+        do ebml_w.tag(c::tag_table_capture_map) |ebml_w| {
             ebml_w.id(id);
-            do ebml_w.tag(c::tag_table_val) {
-                do ebml_w.emit_from_vec(*cap_vars) |cap_var| {
+            do ebml_w.tag(c::tag_table_val) |ebml_w| {
+                do ebml_w.emit_from_vec(*cap_vars) |ebml_w, cap_var| {
                     cap_var.encode(ebml_w);
                 }
             }
@@ -961,40 +943,49 @@ impl doc_decoder_helpers for ebml::Doc {
 }
 
 trait ebml_decoder_decoder_helpers {
-    fn read_arg(&self, xcx: @ExtendedDecodeContext) -> ty::arg;
-    fn read_ty(&self, xcx: @ExtendedDecodeContext) -> ty::t;
-    fn read_tys(&self, xcx: @ExtendedDecodeContext) -> ~[ty::t];
-    fn read_type_param_def(&self, xcx: @ExtendedDecodeContext) -> ty::TypeParameterDef;
-    fn read_ty_param_bounds_and_ty(&self, xcx: @ExtendedDecodeContext)
+    fn read_arg(&mut self, xcx: @ExtendedDecodeContext) -> ty::arg;
+    fn read_ty(&mut self, xcx: @ExtendedDecodeContext) -> ty::t;
+    fn read_tys(&mut self, xcx: @ExtendedDecodeContext) -> ~[ty::t];
+    fn read_type_param_def(&mut self, xcx: @ExtendedDecodeContext)
+                           -> ty::TypeParameterDef;
+    fn read_ty_param_bounds_and_ty(&mut self, xcx: @ExtendedDecodeContext)
                                 -> ty::ty_param_bounds_and_ty;
-    fn convert_def_id(&self, xcx: @ExtendedDecodeContext,
+    fn convert_def_id(&mut self,
+                      xcx: @ExtendedDecodeContext,
                       source: DefIdSource,
-                      did: ast::def_id) -> ast::def_id;
+                      did: ast::def_id)
+                      -> ast::def_id;
 }
 
 impl ebml_decoder_decoder_helpers for reader::Decoder {
-    fn read_arg(&self, xcx: @ExtendedDecodeContext) -> ty::arg {
-        do self.read_opaque |doc| {
+    fn read_arg(&mut self, xcx: @ExtendedDecodeContext) -> ty::arg {
+        do self.read_opaque |this, doc| {
             tydecode::parse_arg_data(
-                doc.data, xcx.dcx.cdata.cnum, doc.start, xcx.dcx.tcx,
-                |s, a| self.convert_def_id(xcx, s, a))
+                doc.data,
+                xcx.dcx.cdata.cnum,
+                doc.start,
+                xcx.dcx.tcx,
+                |s, a| this.convert_def_id(xcx, s, a))
         }
     }
 
-    fn read_ty(&self, xcx: @ExtendedDecodeContext) -> ty::t {
+    fn read_ty(&mut self, xcx: @ExtendedDecodeContext) -> ty::t {
         // Note: regions types embed local node ids.  In principle, we
         // should translate these node ids into the new decode
         // context.  However, we do not bother, because region types
         // are not used during trans.
 
-        return do self.read_opaque |doc| {
-
+        return do self.read_opaque |this, doc| {
             let ty = tydecode::parse_ty_data(
-                doc.data, xcx.dcx.cdata.cnum, doc.start, xcx.dcx.tcx,
-                |s, a| self.convert_def_id(xcx, s, a));
+                doc.data,
+                xcx.dcx.cdata.cnum,
+                doc.start,
+                xcx.dcx.tcx,
+                |s, a| this.convert_def_id(xcx, s, a));
 
             debug!("read_ty(%s) = %s",
-                   type_string(doc), ty_to_str(xcx.dcx.tcx, ty));
+                   type_string(doc),
+                   ty_to_str(xcx.dcx.tcx, ty));
 
             ty
         };
@@ -1008,43 +999,57 @@ impl ebml_decoder_decoder_helpers for reader::Decoder {
         }
     }
 
-    fn read_tys(&self, xcx: @ExtendedDecodeContext) -> ~[ty::t] {
-        self.read_to_vec(|| self.read_ty(xcx) )
+    fn read_tys(&mut self, xcx: @ExtendedDecodeContext) -> ~[ty::t] {
+        self.read_to_vec(|this| this.read_ty(xcx) )
     }
 
-    fn read_type_param_def(&self, xcx: @ExtendedDecodeContext) -> ty::TypeParameterDef {
-        do self.read_opaque |doc| {
+    fn read_type_param_def(&mut self, xcx: @ExtendedDecodeContext)
+                           -> ty::TypeParameterDef {
+        do self.read_opaque |this, doc| {
             tydecode::parse_type_param_def_data(
-                doc.data, doc.start, xcx.dcx.cdata.cnum, xcx.dcx.tcx,
-                |s, a| self.convert_def_id(xcx, s, a))
+                doc.data,
+                doc.start,
+                xcx.dcx.cdata.cnum,
+                xcx.dcx.tcx,
+                |s, a| this.convert_def_id(xcx, s, a))
         }
     }
 
-    fn read_ty_param_bounds_and_ty(&self, xcx: @ExtendedDecodeContext)
-        -> ty::ty_param_bounds_and_ty
-    {
-        do self.read_struct("ty_param_bounds_and_ty", 2) {
+    fn read_ty_param_bounds_and_ty(&mut self, xcx: @ExtendedDecodeContext)
+                                   -> ty::ty_param_bounds_and_ty {
+        do self.read_struct("ty_param_bounds_and_ty", 2) |this| {
             ty::ty_param_bounds_and_ty {
-                generics: do self.read_struct("Generics", 2) {
-                    ty::Generics {
-                        type_param_defs: self.read_struct_field("type_param_defs", 0, || {
-                            @self.read_to_vec(|| self.read_type_param_def(xcx))
-                        }),
-                        region_param: self.read_struct_field(~"region_param", 1, || {
-                            Decodable::decode(self)
-                        })
+                generics: do this.read_struct_field("generics", 0) |this| {
+                    do this.read_struct("Generics", 2) |this| {
+                        ty::Generics {
+                            type_param_defs:
+                                this.read_struct_field("type_param_defs",
+                                                       0,
+                                                       |this| {
+                                    @this.read_to_vec(|this|
+                                        this.read_type_param_def(xcx))
+                            }),
+                            region_param:
+                                this.read_struct_field("region_param",
+                                                       1,
+                                                       |this| {
+                                    Decodable::decode(this)
+                                })
+                        }
                     }
                 },
-                ty: self.read_struct_field("ty", 1, || {
-                    self.read_ty(xcx)
+                ty: this.read_struct_field("ty", 1, |this| {
+                    this.read_ty(xcx)
                 })
             }
         }
     }
 
-    fn convert_def_id(&self, xcx: @ExtendedDecodeContext,
+    fn convert_def_id(&mut self,
+                      xcx: @ExtendedDecodeContext,
                       source: tydecode::DefIdSource,
-                      did: ast::def_id) -> ast::def_id {
+                      did: ast::def_id)
+                      -> ast::def_id {
         /*!
          *
          * Converts a def-id that appears in a type.  The correct
@@ -1084,7 +1089,8 @@ fn decode_side_tables(xcx: @ExtendedDecodeContext,
             dcx.maps.moves_map.insert(id);
         } else {
             let val_doc = entry_doc.get(c::tag_table_val as uint);
-            let val_dsr = &reader::Decoder(val_doc);
+            let mut val_dsr = reader::Decoder(val_doc);
+            let val_dsr = &mut val_dsr;
             if tag == (c::tag_table_def as uint) {
                 let def = decode_def(xcx, val_doc);
                 dcx.tcx.def_map.insert(id, def);
@@ -1097,7 +1103,7 @@ fn decode_side_tables(xcx: @ExtendedDecodeContext,
                 let tys = val_dsr.read_tys(xcx);
                 dcx.tcx.node_type_substs.insert(id, tys);
             } else if tag == (c::tag_table_freevars as uint) {
-                let fv_info = @val_dsr.read_to_vec(|| {
+                let fv_info = @val_dsr.read_to_vec(|val_dsr| {
                     @val_dsr.read_freevar_entry(xcx)
                 });
                 dcx.tcx.freevars.insert(id, fv_info);
@@ -1123,7 +1129,7 @@ fn decode_side_tables(xcx: @ExtendedDecodeContext,
                 let cvars =
                     at_vec::from_owned(
                         val_dsr.read_to_vec(
-                            || val_dsr.read_capture_var(xcx)));
+                            |val_dsr| val_dsr.read_capture_var(xcx)));
                 dcx.maps.capture_map.insert(id, cvars);
             } else {
                 xcx.dcx.tcx.sess.bug(
@@ -1139,17 +1145,17 @@ fn decode_side_tables(xcx: @ExtendedDecodeContext,
 // Testing of astencode_gen
 
 #[cfg(test)]
-fn encode_item_ast(ebml_w: &writer::Encoder, item: @ast::item) {
-    do ebml_w.wr_tag(c::tag_tree as uint) {
-        (*item).encode(ebml_w)
-    }
+fn encode_item_ast(ebml_w: &mut writer::Encoder, item: @ast::item) {
+    ebml_w.start_tag(c::tag_tree as uint);
+    (*item).encode(ebml_w);
+    ebml_w.end_tag();
 }
 
 #[cfg(test)]
 fn decode_item_ast(par_doc: ebml::Doc) -> @ast::item {
     let chi_doc = par_doc.get(c::tag_tree as uint);
-    let d = &reader::Decoder(chi_doc);
-    @Decodable::decode(d)
+    let mut d = reader::Decoder(chi_doc);
+    @Decodable::decode(&mut d)
 }
 
 #[cfg(test)]
@@ -1190,8 +1196,8 @@ fn roundtrip(in_item: Option<@ast::item>) {
 
     let in_item = in_item.get();
     let bytes = do io::with_bytes_writer |wr| {
-        let ebml_w = writer::Encoder(wr);
-        encode_item_ast(&ebml_w, in_item);
+        let mut ebml_w = writer::Encoder(wr);
+        encode_item_ast(&mut ebml_w, in_item);
     };
     let ebml_doc = reader::Doc(@bytes);
     let out_item = decode_item_ast(ebml_doc);
diff --git a/src/librustc/middle/borrowck/check_loans.rs b/src/librustc/middle/borrowck/check_loans.rs
index 25d57662c6e..b9a3f4bd6fc 100644
--- a/src/librustc/middle/borrowck/check_loans.rs
+++ b/src/librustc/middle/borrowck/check_loans.rs
@@ -618,8 +618,7 @@ fn check_loans_in_fn<'a>(fk: &visit::fn_kind,
                          visitor: visit::vt<@mut CheckLoanCtxt<'a>>) {
     match *fk {
         visit::fk_item_fn(*) |
-        visit::fk_method(*) |
-        visit::fk_dtor(*) => {
+        visit::fk_method(*) => {
             // Don't process nested items.
             return;
         }
@@ -761,4 +760,3 @@ fn check_loans_in_block<'a>(blk: &ast::blk,
     visit::visit_block(blk, self, vt);
     self.check_for_conflicting_loans(blk.node.id);
 }
-
diff --git a/src/librustc/middle/borrowck/gather_loans/mod.rs b/src/librustc/middle/borrowck/gather_loans/mod.rs
index 7ac6dfd3ec3..922af0cadec 100644
--- a/src/librustc/middle/borrowck/gather_loans/mod.rs
+++ b/src/librustc/middle/borrowck/gather_loans/mod.rs
@@ -110,8 +110,7 @@ fn gather_loans_in_fn(fk: &visit::fn_kind,
     match fk {
         // Do not visit items here, the outer loop in borrowck/mod
         // will visit them for us in turn.
-        &visit::fk_item_fn(*) | &visit::fk_method(*) |
-        &visit::fk_dtor(*) => {
+        &visit::fk_item_fn(*) | &visit::fk_method(*) => {
             return;
         }
 
diff --git a/src/librustc/middle/borrowck/mod.rs b/src/librustc/middle/borrowck/mod.rs
index a44f743c9ea..c9a4de38307 100644
--- a/src/librustc/middle/borrowck/mod.rs
+++ b/src/librustc/middle/borrowck/mod.rs
@@ -118,8 +118,7 @@ fn borrowck_fn(fk: &visit::fn_kind,
         }
 
         &visit::fk_item_fn(*) |
-        &visit::fk_method(*) |
-        &visit::fk_dtor(*) => {
+        &visit::fk_method(*) => {
             debug!("borrowck_fn(id=%?)", id);
 
             // Check the body of fn items.
@@ -469,11 +468,11 @@ pub impl BorrowckCtxt {
         self.note_and_explain_bckerr(err);
     }
 
-    fn span_err(&self, s: span, m: ~str) {
+    fn span_err(&self, s: span, m: &str) {
         self.tcx.sess.span_err(s, m);
     }
 
-    fn span_note(&self, s: span, m: ~str) {
+    fn span_note(&self, s: span, m: &str) {
         self.tcx.sess.span_note(s, m);
     }
 
diff --git a/src/librustc/middle/check_const.rs b/src/librustc/middle/check_const.rs
index 0bb156dd5f6..9e6d9053237 100644
--- a/src/librustc/middle/check_const.rs
+++ b/src/librustc/middle/check_const.rs
@@ -92,13 +92,13 @@ pub fn check_expr(sess: Session,
           expr_unary(deref, _) => { }
           expr_unary(box(_), _) | expr_unary(uniq(_), _) => {
             sess.span_err(e.span,
-                          ~"disallowed operator in constant expression");
+                          "disallowed operator in constant expression");
             return;
           }
           expr_lit(@codemap::spanned {node: lit_str(_), _}) => { }
           expr_binary(_, _, _) | expr_unary(_, _) => {
             if method_map.contains_key(&e.id) {
-                sess.span_err(e.span, ~"user-defined operators are not \
+                sess.span_err(e.span, "user-defined operators are not \
                                        allowed in constant expressions");
             }
           }
@@ -118,8 +118,8 @@ pub fn check_expr(sess: Session,
             // a path in trans::callee that only works in block contexts.
             if pth.types.len() != 0 {
                 sess.span_err(
-                    e.span, ~"paths in constants may only refer to \
-                              items without type parameters");
+                    e.span, "paths in constants may only refer to \
+                             items without type parameters");
             }
             match def_map.find(&e.id) {
               Some(&def_const(_)) |
@@ -131,11 +131,11 @@ pub fn check_expr(sess: Session,
                 debug!("(checking const) found bad def: %?", def);
                 sess.span_err(
                     e.span,
-                    fmt!("paths in constants may only refer to \
-                          constants or functions"));
+                    "paths in constants may only refer to \
+                     constants or functions");
               }
               None => {
-                sess.span_bug(e.span, ~"unbound path in const?!");
+                sess.span_bug(e.span, "unbound path in const?!");
               }
             }
           }
@@ -146,8 +146,8 @@ pub fn check_expr(sess: Session,
                 _ => {
                     sess.span_err(
                         e.span,
-                        ~"function calls in constants are limited to \
-                          struct and enum constructors");
+                        "function calls in constants are limited to \
+                         struct and enum constructors");
                 }
             }
           }
@@ -163,12 +163,12 @@ pub fn check_expr(sess: Session,
           expr_addr_of(*) => {
                 sess.span_err(
                     e.span,
-                    ~"borrowed pointers in constants may only refer to \
-                      immutable values");
+                    "borrowed pointers in constants may only refer to \
+                     immutable values");
           }
           _ => {
             sess.span_err(e.span,
-                          ~"constant contains unimplemented expression type");
+                          "constant contains unimplemented expression type");
             return;
           }
         }
@@ -178,14 +178,14 @@ pub fn check_expr(sess: Session,
         if t != ty_char {
             if (v as u64) > ast_util::int_ty_max(
                 if t == ty_i { sess.targ_cfg.int_type } else { t }) {
-                sess.span_err(e.span, ~"literal out of range for its type");
+                sess.span_err(e.span, "literal out of range for its type");
             }
         }
       }
       expr_lit(@codemap::spanned {node: lit_uint(v, t), _}) => {
         if v > ast_util::uint_ty_max(
             if t == ty_u { sess.targ_cfg.uint_type } else { t }) {
-            sess.span_err(e.span, ~"literal out of range for its type");
+            sess.span_err(e.span, "literal out of range for its type");
         }
       }
       _ => ()
@@ -224,7 +224,7 @@ pub fn check_item_recursion(sess: Session,
 
     fn visit_item(it: @item, env: env, v: visit::vt<env>) {
         if env.idstack.contains(&(it.id)) {
-            env.sess.span_fatal(env.root_it.span, ~"recursive constant");
+            env.sess.span_fatal(env.root_it.span, "recursive constant");
         }
         env.idstack.push(it.id);
         visit::visit_item(it, env, v);
@@ -253,11 +253,3 @@ pub fn check_item_recursion(sess: Session,
         visit::visit_expr(e, env, v);
     }
 }
-
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
diff --git a/src/librustc/middle/check_loop.rs b/src/librustc/middle/check_loop.rs
index 9f26f7f8372..e3b816fceb8 100644
--- a/src/librustc/middle/check_loop.rs
+++ b/src/librustc/middle/check_loop.rs
@@ -54,17 +54,17 @@ pub fn check_crate(tcx: ty::ctxt, crate: @crate) {
               }
               expr_break(_) => {
                 if !cx.in_loop {
-                    tcx.sess.span_err(e.span, ~"`break` outside of loop");
+                    tcx.sess.span_err(e.span, "`break` outside of loop");
                 }
               }
               expr_again(_) => {
                 if !cx.in_loop {
-                    tcx.sess.span_err(e.span, ~"`again` outside of loop");
+                    tcx.sess.span_err(e.span, "`again` outside of loop");
                 }
               }
               expr_ret(oe) => {
                 if !cx.can_ret {
-                    tcx.sess.span_err(e.span, ~"`return` in block function");
+                    tcx.sess.span_err(e.span, "`return` in block function");
                 }
                 visit::visit_expr_opt(oe, cx, v);
               }
diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs
index 5be0c09f4ae..a50895aa013 100644
--- a/src/librustc/middle/check_match.rs
+++ b/src/librustc/middle/check_match.rs
@@ -94,7 +94,7 @@ pub fn check_expr(cx: @MatchCheckCtxt, ex: @expr, s: (), v: visit::vt<()>) {
        }
        let arms = vec::concat(arms.filter_mapped(unguarded_pat));
        if arms.is_empty() {
-           cx.tcx.sess.span_err(ex.span, ~"non-exhaustive patterns");
+           cx.tcx.sess.span_err(ex.span, "non-exhaustive patterns");
        } else {
            check_exhaustive(cx, ex.span, arms);
        }
@@ -111,7 +111,7 @@ pub fn check_arms(cx: @MatchCheckCtxt, arms: &[arm]) {
             let v = ~[*pat];
             match is_useful(cx, &seen, v) {
               not_useful => {
-                cx.tcx.sess.span_err(pat.span, ~"unreachable pattern");
+                cx.tcx.sess.span_err(pat.span, "unreachable pattern");
               }
               _ => ()
             }
@@ -685,7 +685,7 @@ pub fn check_local(cx: @MatchCheckCtxt,
     visit::visit_local(loc, s, v);
     if is_refutable(cx, loc.node.pat) {
         cx.tcx.sess.span_err(loc.node.pat.span,
-                          ~"refutable pattern in local binding");
+                             "refutable pattern in local binding");
     }
 
     // Check legality of move bindings.
@@ -708,7 +708,7 @@ pub fn check_fn(cx: @MatchCheckCtxt,
     for decl.inputs.each |input| {
         if is_refutable(cx, input.pat) {
             cx.tcx.sess.span_err(input.pat.span,
-                              ~"refutable pattern in function argument");
+                                 "refutable pattern in function argument");
         }
     }
 }
@@ -780,24 +780,24 @@ pub fn check_legality_of_move_bindings(cx: @MatchCheckCtxt,
         if sub.is_some() {
             tcx.sess.span_err(
                 p.span,
-                ~"cannot bind by-move with sub-bindings");
+                "cannot bind by-move with sub-bindings");
         } else if has_guard {
             tcx.sess.span_err(
                 p.span,
-                ~"cannot bind by-move into a pattern guard");
+                "cannot bind by-move into a pattern guard");
         } else if by_ref_span.is_some() {
             tcx.sess.span_err(
                 p.span,
-                ~"cannot bind by-move and by-ref \
-                  in the same pattern");
+                "cannot bind by-move and by-ref \
+                 in the same pattern");
             tcx.sess.span_note(
                 by_ref_span.get(),
-                ~"by-ref binding occurs here");
+                "by-ref binding occurs here");
         } else if is_lvalue {
             tcx.sess.span_err(
                 p.span,
-                ~"cannot bind by-move when \
-                  matching an lvalue");
+                "cannot bind by-move when \
+                 matching an lvalue");
         }
     };
 
@@ -837,9 +837,9 @@ pub fn check_legality_of_move_bindings(cx: @MatchCheckCtxt,
                         {
                             cx.tcx.sess.span_err(
                                 pat.span,
-                                ~"by-move pattern \
-                                  bindings may not occur \
-                                  behind @ or & bindings");
+                                "by-move pattern \
+                                 bindings may not occur \
+                                 behind @ or & bindings");
                         }
 
                         match sub {
@@ -862,11 +862,3 @@ pub fn check_legality_of_move_bindings(cx: @MatchCheckCtxt,
         (vt.visit_pat)(*pat, false, vt);
     }
 }
-
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs
index dea08eedb61..7c1933d6785 100644
--- a/src/librustc/middle/const_eval.rs
+++ b/src/librustc/middle/const_eval.rs
@@ -277,7 +277,7 @@ pub fn eval_const_expr_partial(tcx: middle::ty::ctxt, e: @expr)
               add => Ok(const_float(a + b)),
               subtract => Ok(const_float(a - b)),
               mul => Ok(const_float(a * b)),
-              quot => Ok(const_float(a / b)),
+              div => Ok(const_float(a / b)),
               rem => Ok(const_float(a % b)),
               eq => fromb(a == b),
               lt => fromb(a < b),
@@ -293,8 +293,8 @@ pub fn eval_const_expr_partial(tcx: middle::ty::ctxt, e: @expr)
               add => Ok(const_int(a + b)),
               subtract => Ok(const_int(a - b)),
               mul => Ok(const_int(a * b)),
-              quot if b == 0 => Err(~"attempted quotient with a divisor of zero"),
-              quot => Ok(const_int(a / b)),
+              div if b == 0 => Err(~"attempted to divide by zero"),
+              div => Ok(const_int(a / b)),
               rem if b == 0 => Err(~"attempted remainder with a divisor of zero"),
               rem => Ok(const_int(a % b)),
               and | bitand => Ok(const_int(a & b)),
@@ -315,8 +315,8 @@ pub fn eval_const_expr_partial(tcx: middle::ty::ctxt, e: @expr)
               add => Ok(const_uint(a + b)),
               subtract => Ok(const_uint(a - b)),
               mul => Ok(const_uint(a * b)),
-              quot if b == 0 => Err(~"attempted quotient with a divisor of zero"),
-              quot => Ok(const_uint(a / b)),
+              div if b == 0 => Err(~"attempted to divide by zero"),
+              div => Ok(const_uint(a / b)),
               rem if b == 0 => Err(~"attempted remainder with a divisor of zero"),
               rem => Ok(const_uint(a % b)),
               and | bitand => Ok(const_uint(a & b)),
@@ -482,12 +482,3 @@ pub fn lit_expr_eq(tcx: middle::ty::ctxt, a: @expr, b: @expr) -> bool {
 pub fn lit_eq(a: @lit, b: @lit) -> bool {
     compare_const_vals(&lit_to_const(a), &lit_to_const(b)) == 0
 }
-
-
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
diff --git a/src/librustc/middle/freevars.rs b/src/librustc/middle/freevars.rs
index 4c8d36f93f4..419b75a2ad9 100644
--- a/src/librustc/middle/freevars.rs
+++ b/src/librustc/middle/freevars.rs
@@ -119,11 +119,3 @@ pub fn get_freevars(tcx: ty::ctxt, fid: ast::node_id) -> freevar_info {
 pub fn has_freevars(tcx: ty::ctxt, fid: ast::node_id) -> bool {
     return vec::len(*get_freevars(tcx, fid)) != 0u;
 }
-
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
diff --git a/src/librustc/middle/kind.rs b/src/librustc/middle/kind.rs
index 44090e32880..57c3e7c3b9a 100644
--- a/src/librustc/middle/kind.rs
+++ b/src/librustc/middle/kind.rs
@@ -93,21 +93,21 @@ fn check_struct_safe_for_destructor(cx: Context,
         });
         if !ty::type_is_owned(cx.tcx, struct_ty) {
             cx.tcx.sess.span_err(span,
-                                 ~"cannot implement a destructor on a struct \
-                                   that is not Owned");
+                                 "cannot implement a destructor on a struct \
+                                  that is not Owned");
             cx.tcx.sess.span_note(span,
-                                  ~"use \"#[unsafe_destructor]\" on the \
-                                    implementation to force the compiler to \
-                                    allow this");
+                                  "use \"#[unsafe_destructor]\" on the \
+                                   implementation to force the compiler to \
+                                   allow this");
         }
     } else {
         cx.tcx.sess.span_err(span,
-                             ~"cannot implement a destructor on a struct \
-                               with type parameters");
+                             "cannot implement a destructor on a struct \
+                              with type parameters");
         cx.tcx.sess.span_note(span,
-                              ~"use \"#[unsafe_destructor]\" on the \
-                                implementation to force the compiler to \
-                                allow this");
+                              "use \"#[unsafe_destructor]\" on the \
+                               implementation to force the compiler to \
+                               allow this");
     }
 }
 
@@ -139,27 +139,16 @@ fn check_item(item: @item, cx: Context, visitor: visit::vt<Context>) {
                                 }
                                 _ => {
                                     cx.tcx.sess.span_bug(self_type.span,
-                                                         ~"the self type for \
-                                                           the Drop trait \
-                                                           impl is not a \
-                                                           path");
+                                                         "the self type for \
+                                                          the Drop trait \
+                                                          impl is not a \
+                                                          path");
                                 }
                             }
                         }
                     }
                 }
             }
-            item_struct(struct_def, _) => {
-                match struct_def.dtor {
-                    None => {}
-                    Some(ref dtor) => {
-                        let struct_did = def_id { crate: 0, node: item.id };
-                        check_struct_safe_for_destructor(cx,
-                                                         dtor.span,
-                                                         struct_did);
-                    }
-                }
-            }
             _ => {}
         }
     }
@@ -200,7 +189,7 @@ fn with_appropriate_checker(cx: Context, id: node_id, b: &fn(check_fn)) {
     fn check_for_bare(cx: Context, fv: @freevar_entry) {
         cx.tcx.sess.span_err(
             fv.span,
-            ~"attempted dynamic environment capture");
+            "attempted dynamic environment capture");
     }
 
     let fty = ty::node_id_to_type(cx.tcx, id);
@@ -412,7 +401,7 @@ fn check_imm_free_var(cx: Context, def: def, sp: span) {
             if is_mutbl {
                 cx.tcx.sess.span_err(
                     sp,
-                    ~"mutable variables cannot be implicitly captured");
+                    "mutable variables cannot be implicitly captured");
             }
         }
         def_arg(*) => { /* ok */ }
@@ -454,12 +443,12 @@ pub fn check_durable(tcx: ty::ctxt, ty: ty::t, sp: span) -> bool {
     if !ty::type_is_durable(tcx, ty) {
         match ty::get(ty).sty {
           ty::ty_param(*) => {
-            tcx.sess.span_err(sp, ~"value may contain borrowed \
-                                    pointers; use `'static` bound");
+            tcx.sess.span_err(sp, "value may contain borrowed \
+                                   pointers; use `'static` bound");
           }
           _ => {
-            tcx.sess.span_err(sp, ~"value may contain borrowed \
-                                    pointers");
+            tcx.sess.span_err(sp, "value may contain borrowed \
+                                   pointers");
           }
         }
         false
@@ -584,19 +573,9 @@ pub fn check_kind_bounds_of_cast(cx: Context, source: @expr, target: @expr) {
             if !ty::type_is_owned(cx.tcx, source_ty) {
                 cx.tcx.sess.span_err(
                     target.span,
-                    ~"uniquely-owned trait objects must be sendable");
+                    "uniquely-owned trait objects must be sendable");
             }
         }
         _ => {} // Nothing to do.
     }
 }
-
-//
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
-//
diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs
index 448f33796bc..001218ea0cf 100644
--- a/src/librustc/middle/lang_items.rs
+++ b/src/librustc/middle/lang_items.rs
@@ -41,7 +41,7 @@ pub enum LangItem {
     AddTraitLangItem,           // 5
     SubTraitLangItem,           // 6
     MulTraitLangItem,           // 7
-    QuotTraitLangItem,          // 8
+    DivTraitLangItem,           // 8
     RemTraitLangItem,           // 9
     NegTraitLangItem,           // 10
     NotTraitLangItem,           // 11
@@ -107,7 +107,7 @@ pub impl LanguageItems {
             5  => "add",
             6  => "sub",
             7  => "mul",
-            8  => "quot",
+            8  => "div",
             9  => "rem",
             10 => "neg",
             11 => "not",
@@ -172,8 +172,8 @@ pub impl LanguageItems {
     pub fn mul_trait(&const self) -> def_id {
         self.items[MulTraitLangItem as uint].get()
     }
-    pub fn quot_trait(&const self) -> def_id {
-        self.items[QuotTraitLangItem as uint].get()
+    pub fn div_trait(&const self) -> def_id {
+        self.items[DivTraitLangItem as uint].get()
     }
     pub fn rem_trait(&const self) -> def_id {
         self.items[RemTraitLangItem as uint].get()
@@ -281,7 +281,7 @@ fn LanguageItemCollector(crate: @crate,
     item_refs.insert(@~"add", AddTraitLangItem as uint);
     item_refs.insert(@~"sub", SubTraitLangItem as uint);
     item_refs.insert(@~"mul", MulTraitLangItem as uint);
-    item_refs.insert(@~"quot", QuotTraitLangItem as uint);
+    item_refs.insert(@~"div", DivTraitLangItem as uint);
     item_refs.insert(@~"rem", RemTraitLangItem as uint);
     item_refs.insert(@~"neg", NegTraitLangItem as uint);
     item_refs.insert(@~"not", NotTraitLangItem as uint);
@@ -442,4 +442,3 @@ pub fn collect_language_items(crate: @crate,
     let LanguageItemCollector { items, _ } = collector;
     items
 }
-
diff --git a/src/librustc/middle/lint.rs b/src/librustc/middle/lint.rs
index c54ff6075fa..b0d6d477c0c 100644
--- a/src/librustc/middle/lint.rs
+++ b/src/librustc/middle/lint.rs
@@ -57,7 +57,6 @@ pub enum lint {
     type_limits,
     default_methods,
     deprecated_mutable_fields,
-    deprecated_drop,
     unused_unsafe,
 
     managed_heap_memory,
@@ -210,13 +209,6 @@ pub fn get_lint_dict() -> LintDict {
             default: deny
         }),
 
-        (~"deprecated_drop",
-         LintSpec {
-            lint: deprecated_drop,
-            desc: "deprecated \"drop\" notation for the destructor",
-            default: deny
-        }),
-
         (~"unused_unsafe",
          LintSpec {
             lint: unused_unsafe,
@@ -346,14 +338,14 @@ pub impl Context {
                           _ => {
                             self.sess.span_err(
                                 meta.span,
-                                ~"malformed lint attribute");
+                                "malformed lint attribute");
                           }
                         }
                     }
                   }
                   _  => {
                     self.sess.span_err(meta.span,
-                                       ~"malformed lint attribute");
+                                       "malformed lint attribute");
                   }
                 }
             }
@@ -463,7 +455,6 @@ fn check_item(i: @ast::item, cx: ty::ctxt) {
     check_item_type_limits(cx, i);
     check_item_default_methods(cx, i);
     check_item_deprecated_mutable_fields(cx, i);
-    check_item_deprecated_drop(cx, i);
     check_item_unused_unsafe(cx, i);
     check_item_unused_mut(cx, i);
 }
@@ -494,8 +485,8 @@ fn check_item_while_true(cx: ty::ctxt, it: @ast::item) {
                                 cx.sess.span_lint(
                                     while_true, e.id, it.id,
                                     e.span,
-                                    ~"denote infinite loops \
-                                      with loop { ... }");
+                                    "denote infinite loops \
+                                     with loop { ... }");
                             }
                             _ => ()
                         }
@@ -612,7 +603,7 @@ fn check_item_type_limits(cx: ty::ctxt, it: @ast::item) {
                     && !check_limits(cx, *binop, l, r) {
                     cx.sess.span_lint(
                         type_limits, e.id, it.id, e.span,
-                        ~"comparison is useless due to type limits");
+                        "comparison is useless due to type limits");
                 }
             }
             _ => ()
@@ -639,7 +630,7 @@ fn check_item_default_methods(cx: ty::ctxt, item: @ast::item) {
                             item.id,
                             item.id,
                             item.span,
-                            ~"default methods are experimental");
+                            "default methods are experimental");
                     }
                 }
             }
@@ -658,7 +649,7 @@ fn check_item_deprecated_mutable_fields(cx: ty::ctxt, item: @ast::item) {
                                           item.id,
                                           item.id,
                                           field.span,
-                                          ~"mutable fields are deprecated");
+                                          "mutable fields are deprecated");
                     }
                     ast::named_field(*) | ast::unnamed_field => {}
                 }
@@ -668,26 +659,6 @@ fn check_item_deprecated_mutable_fields(cx: ty::ctxt, item: @ast::item) {
     }
 }
 
-fn check_item_deprecated_drop(cx: ty::ctxt, item: @ast::item) {
-    match item.node {
-        ast::item_struct(struct_def, _) => {
-            match struct_def.dtor {
-                None => {}
-                Some(ref dtor) => {
-                    cx.sess.span_lint(deprecated_drop,
-                                      item.id,
-                                      item.id,
-                                      dtor.span,
-                                      ~"`drop` notation for destructors is \
-                                        deprecated; implement the `Drop` \
-                                        trait instead");
-                }
-            }
-        }
-        _ => {}
-    }
-}
-
 fn check_item_ctypes(cx: ty::ctxt, it: @ast::item) {
 
     fn check_foreign_fn(cx: ty::ctxt, fn_id: ast::node_id,
@@ -701,14 +672,14 @@ fn check_item_ctypes(cx: ty::ctxt, it: @ast::item) {
                     cx.sess.span_lint(
                         ctypes, id, fn_id,
                         ty.span,
-                        ~"found rust type `int` in foreign module, while \
+                        "found rust type `int` in foreign module, while \
                          libc::c_int or libc::c_long should be used");
                   }
                   ast::def_prim_ty(ast::ty_uint(ast::ty_u)) => {
                     cx.sess.span_lint(
                         ctypes, id, fn_id,
                         ty.span,
-                        ~"found rust type `uint` in foreign module, while \
+                        "found rust type `uint` in foreign module, while \
                          libc::c_uint or libc::c_ulong should be used");
                   }
                   _ => ()
@@ -824,7 +795,7 @@ fn check_item_path_statement(cx: ty::ctxt, it: @ast::item) {
                         cx.sess.span_lint(
                             path_statement, id, it.id,
                             s.span,
-                            ~"path statement with no effect");
+                            "path statement with no effect");
                     }
                     _ => ()
                 }
@@ -864,8 +835,8 @@ fn check_item_non_camel_case_types(cx: ty::ctxt, it: @ast::item) {
         if !is_camel_case(cx, ident) {
             cx.sess.span_lint(
                 non_camel_case_types, expr_id, item_id, span,
-                ~"type, variant, or trait should have \
-                  a camel case identifier");
+                "type, variant, or trait should have \
+                 a camel case identifier");
         }
     }
 
@@ -892,7 +863,7 @@ fn check_item_unused_unsafe(cx: ty::ctxt, it: @ast::item) {
                 if !cx.used_unsafe.contains(&blk.node.id) {
                     cx.sess.span_lint(unused_unsafe, blk.node.id, it.id,
                                       blk.span,
-                                      ~"unnecessary `unsafe` block");
+                                      "unnecessary `unsafe` block");
                 }
             }
             _ => ()
@@ -917,9 +888,9 @@ fn check_item_unused_mut(tcx: ty::ctxt, it: @ast::item) {
         }
         if !used {
             let msg = if bindings == 1 {
-                ~"variable does not need to be mutable"
+                "variable does not need to be mutable"
             } else {
-                ~"variables do not need to be mutable"
+                "variables do not need to be mutable"
             };
             tcx.sess.span_lint(unused_mut, p.id, it.id, p.span, msg);
         }
@@ -975,13 +946,3 @@ pub fn check_crate(tcx: ty::ctxt, crate: @ast::crate) {
 
     tcx.sess.abort_if_errors();
 }
-
-//
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
-//
diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs
index 60ce34c3af2..0bd73a15d50 100644
--- a/src/librustc/middle/liveness.rs
+++ b/src/librustc/middle/liveness.rs
@@ -116,7 +116,7 @@ use syntax::ast::*;
 use syntax::codemap::span;
 use syntax::parse::token::special_idents;
 use syntax::print::pprust::{expr_to_str, block_to_str};
-use syntax::visit::{fk_anon, fk_dtor, fk_fn_block, fk_item_fn, fk_method};
+use syntax::visit::{fk_anon, fk_fn_block, fk_item_fn, fk_method};
 use syntax::visit::{vt};
 use syntax::{visit, ast_util};
 
@@ -331,7 +331,7 @@ pub impl IrMaps {
         match self.capture_info_map.find(&expr.id) {
           Some(&caps) => caps,
           None => {
-            self.tcx.sess.span_bug(expr.span, ~"no registered caps");
+            self.tcx.sess.span_bug(expr.span, "no registered caps");
           }
         }
     }
@@ -389,9 +389,6 @@ fn visit_fn(fk: &visit::fn_kind,
                 sty_static => {}
             }
         }
-        fk_dtor(_, _, self_id, _) => {
-            fn_maps.add_variable(Arg(self_id, special_idents::self_));
-        }
         fk_item_fn(*) | fk_anon(*) | fk_fn_block(*) => {}
     }
 
@@ -639,7 +636,7 @@ pub impl Liveness {
           }
           None => {
             self.tcx.sess.span_bug(
-                span, ~"Not present in def map")
+                span, "Not present in def map")
           }
         }
     }
@@ -756,8 +753,8 @@ pub impl Liveness {
                       // to find with one
                 match self.tcx.def_map.find(&id) {
                     Some(&def_label(loop_id)) => loop_id,
-                    _ => self.tcx.sess.span_bug(sp, ~"Label on break/loop \
-                                                    doesn't refer to a loop")
+                    _ => self.tcx.sess.span_bug(sp, "Label on break/loop \
+                                                     doesn't refer to a loop")
                 },
             None => {
                 // Vanilla 'break' or 'loop', so use the enclosing
@@ -948,7 +945,7 @@ pub impl Liveness {
           }
 
           stmt_mac(*) => {
-            self.tcx.sess.span_bug(stmt.span, ~"unexpanded macro");
+            self.tcx.sess.span_bug(stmt.span, "unexpanded macro");
           }
         }
     }
@@ -1118,7 +1115,7 @@ pub impl Liveness {
               match self.break_ln.find(&sc) {
                   Some(&b) => b,
                   None => self.tcx.sess.span_bug(expr.span,
-                                ~"Break to unknown label")
+                                                 "Break to unknown label")
               }
           }
 
@@ -1132,7 +1129,7 @@ pub impl Liveness {
               match self.cont_ln.find(&sc) {
                   Some(&b) => b,
                   None => self.tcx.sess.span_bug(expr.span,
-                                ~"Loop to unknown label")
+                                                 "Loop to unknown label")
               }
           }
 
@@ -1258,7 +1255,7 @@ pub impl Liveness {
           }
 
           expr_mac(*) => {
-            self.tcx.sess.span_bug(expr.span, ~"unexpanded macro");
+            self.tcx.sess.span_bug(expr.span, "unexpanded macro");
           }
         }
     }
@@ -1570,10 +1567,10 @@ pub impl Liveness {
             } else if ty::type_is_bot(t_ret) {
                 // for bot return types, not ok.  Function should fail.
                 self.tcx.sess.span_err(
-                    sp, ~"some control paths may return");
+                    sp, "some control paths may return");
             } else {
                 self.tcx.sess.span_err(
-                    sp, ~"not all control paths return a value");
+                    sp, "not all control paths return a value");
             }
         }
     }
@@ -1654,10 +1651,10 @@ pub impl Liveness {
               None => {
                 self.tcx.sess.span_err(
                     span,
-                    ~"re-assignment of immutable variable");
+                    "re-assignment of immutable variable");
                 self.tcx.sess.span_note(
                     orig_span,
-                    ~"prior assignment occurs here");
+                    "prior assignment occurs here");
               }
             }
           }
diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs
index da0a3ba25d0..dde4c044792 100644
--- a/src/librustc/middle/mem_categorization.rs
+++ b/src/librustc/middle/mem_categorization.rs
@@ -847,7 +847,7 @@ pub impl mem_categorization_ctxt {
                 _ => {
                     self.tcx.sess.span_bug(
                         pat.span,
-                        ~"enum pattern didn't resolve to enum or struct");
+                        "enum pattern didn't resolve to enum or struct");
                 }
             }
           }
diff --git a/src/librustc/middle/moves.rs b/src/librustc/middle/moves.rs
index 58345302d16..040ff30f9e6 100644
--- a/src/librustc/middle/moves.rs
+++ b/src/librustc/middle/moves.rs
@@ -450,7 +450,7 @@ pub impl VisitContext {
                     MoveInWhole => {
                         self.tcx.sess.span_bug(
                             expr.span,
-                            fmt!("Component mode can never be MoveInWhole"));
+                            "Component mode can never be MoveInWhole");
                     }
                 }
             }
@@ -673,7 +673,7 @@ pub impl VisitContext {
             expr_mac(*) => {
                 self.tcx.sess.span_bug(
                     expr.span,
-                    ~"macro expression remains after expansion");
+                    "macro expression remains after expansion");
             }
         }
     }
diff --git a/src/librustc/middle/pat_util.rs b/src/librustc/middle/pat_util.rs
index 3ca79982b7b..b87adb75bc3 100644
--- a/src/librustc/middle/pat_util.rs
+++ b/src/librustc/middle/pat_util.rs
@@ -86,4 +86,3 @@ pub fn pat_binding_ids(dm: resolve::DefMap, pat: @pat) -> ~[node_id] {
     pat_bindings(dm, pat, |_bm, b_id, _sp, _pt| found.push(b_id) );
     return found;
 }
-
diff --git a/src/librustc/middle/privacy.rs b/src/librustc/middle/privacy.rs
index 0df09553ad0..ce0f124da74 100644
--- a/src/librustc/middle/privacy.rs
+++ b/src/librustc/middle/privacy.rs
@@ -99,8 +99,8 @@ pub fn check_crate(tcx: ty::ctxt,
                                          parental_privacy == Public)
                                          == Private {
             tcx.sess.span_err(span,
-                ~"can only dereference enums \
-                  with a single, public variant");
+                "can only dereference enums \
+                 with a single, public variant");
         }
     };
 
@@ -121,8 +121,8 @@ pub fn check_crate(tcx: ty::ctxt,
                                             tcx.sess.parse_sess.interner)));
             }
             None => {
-                tcx.sess.span_bug(span, ~"method not found in \
-                                          AST map?!");
+                tcx.sess.span_bug(span, "method not found in \
+                                         AST map?!");
             }
         }
     };
@@ -140,8 +140,8 @@ pub fn check_crate(tcx: ty::ctxt,
                 // Look up the enclosing impl.
                 if container_id.crate != local_crate {
                     tcx.sess.span_bug(span,
-                                      ~"local method isn't in local \
-                                        impl?!");
+                                      "local method isn't in local \
+                                       impl?!");
                 }
 
                 match tcx.items.find(&container_id.node) {
@@ -155,10 +155,10 @@ pub fn check_crate(tcx: ty::ctxt,
                         }
                     }
                     Some(_) => {
-                        tcx.sess.span_bug(span, ~"impl wasn't an item?!");
+                        tcx.sess.span_bug(span, "impl wasn't an item?!");
                     }
                     None => {
-                        tcx.sess.span_bug(span, ~"impl wasn't in AST map?!");
+                        tcx.sess.span_bug(span, "impl wasn't in AST map?!");
                     }
                 }
             }
@@ -185,8 +185,8 @@ pub fn check_crate(tcx: ty::ctxt,
                                             tcx.sess.parse_sess.interner)));
             }
             None => {
-                tcx.sess.span_bug(span, ~"method not found in \
-                                          AST map?!");
+                tcx.sess.span_bug(span, "method not found in \
+                                         AST map?!");
             }
         }
     };
@@ -219,7 +219,7 @@ pub fn check_crate(tcx: ty::ctxt,
                                                    .interner)));
                 }
                 None => {
-                    tcx.sess.span_bug(span, ~"item not found in AST map?!");
+                    tcx.sess.span_bug(span, "item not found in AST map?!");
                 }
             }
         };
@@ -333,10 +333,10 @@ pub fn check_crate(tcx: ty::ctxt,
                             match item.node {
                                 item_trait(_, _, ref methods) => {
                                     if method_num >= (*methods).len() {
-                                        tcx.sess.span_bug(span, ~"method \
-                                                                  number \
-                                                                  out of \
-                                                                  range?!");
+                                        tcx.sess.span_bug(span, "method \
+                                                                 number \
+                                                                 out of \
+                                                                 range?!");
                                     }
                                     match (*methods)[method_num] {
                                         provided(method)
@@ -363,20 +363,20 @@ pub fn check_crate(tcx: ty::ctxt,
                                     }
                                 }
                                 _ => {
-                                    tcx.sess.span_bug(span, ~"trait wasn't \
-                                                              actually a \
-                                                              trait?!");
+                                    tcx.sess.span_bug(span, "trait wasn't \
+                                                             actually a \
+                                                             trait?!");
                                 }
                             }
                         }
                         Some(_) => {
-                            tcx.sess.span_bug(span, ~"trait wasn't an \
-                                                      item?!");
+                            tcx.sess.span_bug(span, "trait wasn't an \
+                                                     item?!");
                         }
                         None => {
-                            tcx.sess.span_bug(span, ~"trait item wasn't \
-                                                      found in the AST \
-                                                      map?!");
+                            tcx.sess.span_bug(span, "trait item wasn't \
+                                                     found in the AST \
+                                                     map?!");
                         }
                     }
                 } else {
@@ -465,8 +465,8 @@ pub fn check_crate(tcx: ty::ctxt,
                             match method_map.find(&expr.id) {
                                 None => {
                                     tcx.sess.span_bug(expr.span,
-                                                      ~"method call not in \
-                                                        method map");
+                                                      "method call not in \
+                                                       method map");
                                 }
                                 Some(ref entry) => {
                                     debug!("(privacy checking) checking \
@@ -512,18 +512,18 @@ pub fn check_crate(tcx: ty::ctxt,
                                     }
                                     _ => {
                                         tcx.sess.span_bug(expr.span,
-                                                          ~"resolve didn't \
-                                                            map enum struct \
-                                                            constructor to a \
-                                                            variant def");
+                                                          "resolve didn't \
+                                                           map enum struct \
+                                                           constructor to a \
+                                                           variant def");
                                     }
                                 }
                             }
                         }
                         _ => {
-                            tcx.sess.span_bug(expr.span, ~"struct expr \
-                                                           didn't have \
-                                                           struct type?!");
+                            tcx.sess.span_bug(expr.span, "struct expr \
+                                                          didn't have \
+                                                          struct type?!");
                         }
                     }
                 }
@@ -579,18 +579,18 @@ pub fn check_crate(tcx: ty::ctxt,
                                     }
                                     _ => {
                                         tcx.sess.span_bug(pattern.span,
-                                                          ~"resolve didn't \
-                                                            map enum struct \
-                                                            pattern to a \
-                                                            variant def");
+                                                          "resolve didn't \
+                                                           map enum struct \
+                                                           pattern to a \
+                                                           variant def");
                                     }
                                 }
                             }
                         }
                         _ => {
                             tcx.sess.span_bug(pattern.span,
-                                              ~"struct pattern didn't have \
-                                                struct type?!");
+                                              "struct pattern didn't have \
+                                               struct type?!");
                         }
                     }
                 }
@@ -603,4 +603,3 @@ pub fn check_crate(tcx: ty::ctxt,
     });
     visit::visit_crate(crate, method_map, visitor);
 }
-
diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs
index d23a798b623..5834ae1d780 100644
--- a/src/librustc/middle/region.rs
+++ b/src/librustc/middle/region.rs
@@ -334,7 +334,7 @@ pub impl RegionMaps {
 pub fn parent_id(cx: Context, span: span) -> ast::node_id {
     match cx.parent {
       None => {
-        cx.sess.span_bug(span, ~"crate should not be parent here");
+        cx.sess.span_bug(span, "crate should not be parent here");
       }
       Some(parent_id) => {
         parent_id
@@ -464,8 +464,7 @@ pub fn resolve_fn(fk: &visit::fn_kind,
     // or it continues with the inherited scope (closures).
     let body_cx = match *fk {
         visit::fk_item_fn(*) |
-        visit::fk_method(*) |
-        visit::fk_dtor(*) => {
+        visit::fk_method(*) => {
             Context {parent: None, var_parent: None, ..cx}
         }
         visit::fk_anon(*) |
@@ -980,4 +979,3 @@ pub fn determine_rp_in_crate(sess: Session,
     // return final set
     return cx.region_paramd_items;
 }
-
diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs
index 8e83ea7e32e..911e265e616 100644
--- a/src/librustc/middle/resolve.rs
+++ b/src/librustc/middle/resolve.rs
@@ -33,7 +33,7 @@ use syntax::ast::{def_upvar, def_use, def_variant, expr, expr_assign_op};
 use syntax::ast::{expr_binary, expr_break, expr_field};
 use syntax::ast::{expr_fn_block, expr_index, expr_method_call, expr_path};
 use syntax::ast::{def_prim_ty, def_region, def_self, def_ty, def_ty_param};
-use syntax::ast::{def_upvar, def_use, def_variant, quot, eq};
+use syntax::ast::{def_upvar, def_use, def_variant, div, eq};
 use syntax::ast::{expr, expr_again, expr_assign_op};
 use syntax::ast::{expr_index, expr_loop};
 use syntax::ast::{expr_path, expr_struct, expr_unary, fn_decl};
@@ -47,7 +47,7 @@ use syntax::ast::{named_field, ne, neg, node_id, pat, pat_enum, pat_ident};
 use syntax::ast::{Path, pat_lit, pat_range, pat_struct};
 use syntax::ast::{prim_ty, private, provided};
 use syntax::ast::{public, required, rem, self_ty_, shl, shr, stmt_decl};
-use syntax::ast::{struct_dtor, struct_field, struct_variant_kind};
+use syntax::ast::{struct_field, struct_variant_kind};
 use syntax::ast::{sty_static, subtract, trait_ref, tuple_variant_kind, Ty};
 use syntax::ast::{ty_bool, ty_char, ty_f, ty_f32, ty_f64, ty_float, ty_i};
 use syntax::ast::{ty_i16, ty_i32, ty_i64, ty_i8, ty_int, TyParam, ty_path};
@@ -3512,7 +3512,6 @@ pub impl Resolver {
                 self.resolve_struct(item.id,
                                     generics,
                                     struct_def.fields,
-                                    &struct_def.dtor,
                                     visitor);
             }
 
@@ -3770,7 +3769,6 @@ pub impl Resolver {
                       id: node_id,
                       generics: &Generics,
                       fields: &[@struct_field],
-                      optional_destructor: &Option<struct_dtor>,
                       visitor: ResolveVisitor) {
         // If applicable, create a rib for the type parameters.
         do self.with_type_parameter_rib(HasTypeParameters
@@ -3784,23 +3782,6 @@ pub impl Resolver {
             for fields.each |field| {
                 self.resolve_type(field.node.ty, visitor);
             }
-
-            // Resolve the destructor, if applicable.
-            match *optional_destructor {
-                None => {
-                    // Nothing to do.
-                }
-                Some(ref destructor) => {
-                    self.resolve_function(NormalRibKind,
-                                          None,
-                                          NoTypeParameters,
-                                          &destructor.node.body,
-                                          HasSelfBinding
-                                            ((*destructor).node.self_id,
-                                             true),
-                                          visitor);
-                }
-            }
         }
     }
 
@@ -4899,9 +4880,9 @@ pub impl Resolver {
                 self.add_fixed_trait_for_expr(expr.id,
                                               self.lang_items.mul_trait());
             }
-            expr_binary(quot, _, _) | expr_assign_op(quot, _, _) => {
+            expr_binary(div, _, _) | expr_assign_op(div, _, _) => {
                 self.add_fixed_trait_for_expr(expr.id,
-                                              self.lang_items.quot_trait());
+                                              self.lang_items.div_trait());
             }
             expr_binary(rem, _, _) | expr_assign_op(rem, _, _) => {
                 self.add_fixed_trait_for_expr(expr.id,
diff --git a/src/librustc/middle/resolve_stage0.rs b/src/librustc/middle/resolve_stage0.rs
index ff46abaf712..2773710ca98 100644
--- a/src/librustc/middle/resolve_stage0.rs
+++ b/src/librustc/middle/resolve_stage0.rs
@@ -33,7 +33,7 @@ use syntax::ast::{def_upvar, def_use, def_variant, expr, expr_assign_op};
 use syntax::ast::{expr_binary, expr_break, expr_field};
 use syntax::ast::{expr_fn_block, expr_index, expr_method_call, expr_path};
 use syntax::ast::{def_prim_ty, def_region, def_self, def_ty, def_ty_param};
-use syntax::ast::{def_upvar, def_use, def_variant, quot, eq};
+use syntax::ast::{def_upvar, def_use, def_variant, div, eq};
 use syntax::ast::{expr, expr_again, expr_assign_op};
 use syntax::ast::{expr_index, expr_loop};
 use syntax::ast::{expr_path, expr_struct, expr_unary, fn_decl};
@@ -47,7 +47,7 @@ use syntax::ast::{named_field, ne, neg, node_id, pat, pat_enum, pat_ident};
 use syntax::ast::{Path, pat_lit, pat_range, pat_struct};
 use syntax::ast::{prim_ty, private, provided};
 use syntax::ast::{public, required, rem, self_ty_, shl, shr, stmt_decl};
-use syntax::ast::{struct_dtor, struct_field, struct_variant_kind};
+use syntax::ast::{struct_field, struct_variant_kind};
 use syntax::ast::{sty_static, subtract, trait_ref, tuple_variant_kind, Ty};
 use syntax::ast::{ty_bool, ty_char, ty_f, ty_f32, ty_f64, ty_float, ty_i};
 use syntax::ast::{ty_i16, ty_i32, ty_i64, ty_i8, ty_int, TyParam, ty_path};
@@ -971,7 +971,7 @@ pub impl Resolver {
                 module_.children.insert(name, child);
                 return (child, new_parent);
             }
-            Some(&child) => {
+            Some(child) => {
                 // Enforce the duplicate checking mode:
                 //
                 // * If we're requesting duplicate module checking, check that
@@ -1033,7 +1033,7 @@ pub impl Resolver {
                                   *self.session.str_of(name)));
                     }
                 }
-                return (child, new_parent);
+                return (*child, new_parent);
             }
         }
     }
@@ -1864,7 +1864,7 @@ pub impl Resolver {
                        *self.session.str_of(target));
 
                 match module_.import_resolutions.find(&target) {
-                    Some(&resolution) => {
+                    Some(resolution) => {
                         debug!("(building import directive) bumping \
                                 reference");
                         resolution.outstanding_references += 1;
@@ -2395,7 +2395,7 @@ pub impl Resolver {
                         (*ident, new_import_resolution);
                 }
                 None => { /* continue ... */ }
-                Some(&dest_import_resolution) => {
+                Some(dest_import_resolution) => {
                     // Merge the two import resolutions at a finer-grained
                     // level.
 
@@ -2433,8 +2433,8 @@ pub impl Resolver {
                     module_.import_resolutions.insert
                         (*ident, dest_import_resolution);
                 }
-                Some(&existing_import_resolution) => {
-                    dest_import_resolution = existing_import_resolution;
+                Some(existing_import_resolution) => {
+                    dest_import_resolution = *existing_import_resolution;
                 }
             }
 
@@ -3512,7 +3512,6 @@ pub impl Resolver {
                 self.resolve_struct(item.id,
                                     generics,
                                     struct_def.fields,
-                                    &struct_def.dtor,
                                     visitor);
             }
 
@@ -3770,7 +3769,6 @@ pub impl Resolver {
                       id: node_id,
                       generics: &Generics,
                       fields: &[@struct_field],
-                      optional_destructor: &Option<struct_dtor>,
                       visitor: ResolveVisitor) {
         // If applicable, create a rib for the type parameters.
         do self.with_type_parameter_rib(HasTypeParameters
@@ -3784,23 +3782,6 @@ pub impl Resolver {
             for fields.each |field| {
                 self.resolve_type(field.node.ty, visitor);
             }
-
-            // Resolve the destructor, if applicable.
-            match *optional_destructor {
-                None => {
-                    // Nothing to do.
-                }
-                Some(ref destructor) => {
-                    self.resolve_function(NormalRibKind,
-                                          None,
-                                          NoTypeParameters,
-                                          &destructor.node.body,
-                                          HasSelfBinding
-                                            ((*destructor).node.self_id,
-                                             true),
-                                          visitor);
-                }
-            }
         }
     }
 
@@ -4901,9 +4882,9 @@ pub impl Resolver {
                 self.add_fixed_trait_for_expr(expr.id,
                                               self.lang_items.mul_trait());
             }
-            expr_binary(quot, _, _) | expr_assign_op(quot, _, _) => {
+            expr_binary(div, _, _) | expr_assign_op(div, _, _) => {
                 self.add_fixed_trait_for_expr(expr.id,
-                                              self.lang_items.quot_trait());
+                                              self.lang_items.div_trait());
             }
             expr_binary(rem, _, _) | expr_assign_op(rem, _, _) => {
                 self.add_fixed_trait_for_expr(expr.id,
@@ -5267,7 +5248,7 @@ pub impl Resolver {
 
         debug!("Import resolutions:");
         for module_.import_resolutions.each |name, import_resolution| {
-            let value_repr;
+            let mut value_repr;
             match import_resolution.target_for_namespace(ValueNS) {
                 None => { value_repr = ~""; }
                 Some(_) => {
@@ -5276,7 +5257,7 @@ pub impl Resolver {
                 }
             }
 
-            let type_repr;
+            let mut type_repr;
             match import_resolution.target_for_namespace(TypeNS) {
                 None => { type_repr = ~""; }
                 Some(_) => {
diff --git a/src/librustc/middle/subst.rs b/src/librustc/middle/subst.rs
index c3a79373931..bf64134704a 100644
--- a/src/librustc/middle/subst.rs
+++ b/src/librustc/middle/subst.rs
@@ -186,4 +186,3 @@ impl Subst for ty::ty_param_bounds_and_ty {
         }
     }
 }
-
diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs
index 61a8b367d6c..d074a2f796f 100644
--- a/src/librustc/middle/trans/_match.rs
+++ b/src/librustc/middle/trans/_match.rs
@@ -557,8 +557,7 @@ pub fn enter_opt<'r>(bcx: block,
                             struct_id = found_struct_id;
                         }
                         _ => {
-                            tcx.sess.span_bug(p.span, ~"expected enum \
-                                                        variant def");
+                            tcx.sess.span_bug(p.span, "expected enum variant def");
                         }
                     }
 
@@ -1882,11 +1881,3 @@ pub fn bind_irrefutable_pat(bcx: block,
     }
     return bcx;
 }
-
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
diff --git a/src/librustc/middle/trans/adt.rs b/src/librustc/middle/trans/adt.rs
index b3e24fcc939..0ee2a2c4cb1 100644
--- a/src/librustc/middle/trans/adt.rs
+++ b/src/librustc/middle/trans/adt.rs
@@ -409,8 +409,8 @@ pub fn num_args(r: &Repr, discr: int) -> uint {
             st.fields.len() - (if dtor { 1 } else { 0 })
         }
         General(ref cases) => cases[discr as uint].fields.len() - 1,
-        NullablePointer{ nonnull: ref nonnull, nndiscr, _ } => {
-            if discr == nndiscr { nonnull.fields.len() } else { 0 }
+        NullablePointer{ nonnull: ref nonnull, nndiscr, nullfields: ref nullfields, _ } => {
+            if discr == nndiscr { nonnull.fields.len() } else { nullfields.len() }
         }
     }
 }
diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs
index 8082e9cce51..90dd9103011 100644
--- a/src/librustc/middle/trans/base.rs
+++ b/src/librustc/middle/trans/base.rs
@@ -777,10 +777,10 @@ pub fn cast_shift_rhs(op: ast::binop,
     }
 }
 
-pub fn fail_if_zero(cx: block, span: span, quotrem: ast::binop,
+pub fn fail_if_zero(cx: block, span: span, divrem: ast::binop,
                     rhs: ValueRef, rhs_t: ty::t) -> block {
-    let text = if quotrem == ast::quot {
-        @~"attempted quotient with a divisor of zero"
+    let text = if divrem == ast::div {
+        @~"attempted to divide by zero"
     } else {
         @~"attempted remainder with a divisor of zero"
     };
@@ -1099,10 +1099,11 @@ pub fn init_local(bcx: block, local: @ast::local) -> block {
     }
 
     let llptr = match bcx.fcx.lllocals.find(&local.node.id) {
-      Some(&local_mem(v)) => v,
-      _ => { bcx.tcx().sess.span_bug(local.span,
-                        ~"init_local: Someone forgot to document why it's\
-                         safe to assume local.node.init must be local_mem!");
+        Some(&local_mem(v)) => v,
+        _ => {
+            bcx.tcx().sess.span_bug(local.span,
+                                    "init_local: Someone forgot to document why it's\
+                                     safe to assume local.node.init must be local_mem!");
         }
     };
 
@@ -2045,6 +2046,7 @@ pub fn trans_tuple_struct(ccx: @CrateContext,
     let bcx = copy_args_to_allocas(fcx, bcx, fn_args, raw_llargs, arg_tys);
 
     let repr = adt::represent_type(ccx, tup_ty);
+    adt::trans_start_init(bcx, repr, fcx.llretptr.get(), 0);
 
     for fields.eachi |i, field| {
         let lldestptr = adt::trans_field_ptr(bcx,
@@ -2067,56 +2069,8 @@ pub fn trans_tuple_struct(ccx: @CrateContext,
     finish_fn(fcx, lltop);
 }
 
-pub fn trans_struct_dtor(ccx: @CrateContext,
-                         path: path,
-                         body: &ast::blk,
-                         dtor_id: ast::node_id,
-                         psubsts: Option<@param_substs>,
-                         hash_id: Option<mono_id>,
-                         parent_id: ast::def_id)
-                      -> ValueRef {
-  let tcx = ccx.tcx;
-  /* Look up the parent class's def_id */
-  let mut class_ty = ty::lookup_item_type(tcx, parent_id).ty;
-  /* Substitute in the class type if necessary */
-  for psubsts.each |ss| {
-    class_ty = ty::subst_tps(tcx, ss.tys, ss.self_ty, class_ty);
-  }
-
-  /* The dtor takes a (null) output pointer, and a self argument,
-     and returns () */
-  let lldty = type_of_dtor(ccx, class_ty);
-
-  // XXX: Bad copies.
-  let s = get_dtor_symbol(ccx, copy path, dtor_id, psubsts);
-
-  /* Register the dtor as a function. It has external linkage */
-  let lldecl = decl_internal_cdecl_fn(ccx.llmod, s, lldty);
-  lib::llvm::SetLinkage(lldecl, lib::llvm::ExternalLinkage);
-
-  /* If we're monomorphizing, register the monomorphized decl
-     for the dtor */
-  for hash_id.each |h_id| {
-    ccx.monomorphized.insert(*h_id, lldecl);
-  }
-  /* Translate the dtor body */
-  let decl = ast_util::dtor_dec();
-  trans_fn(ccx,
-           path,
-           &decl,
-           body,
-           lldecl,
-           impl_self(class_ty),
-           psubsts,
-           dtor_id,
-           None,
-           []);
-  lldecl
-}
-
 pub fn trans_enum_def(ccx: @CrateContext, enum_definition: &ast::enum_def,
-                      id: ast::node_id,
-                      path: @ast_map::path, vi: @~[ty::VariantInfo],
+                      id: ast::node_id, vi: @~[ty::VariantInfo],
                       i: &mut uint) {
     for vec::each(enum_definition.variants) |variant| {
         let disr_val = vi[*i].disr_val;
@@ -2132,8 +2086,7 @@ pub fn trans_enum_def(ccx: @CrateContext, enum_definition: &ast::enum_def,
                 // Nothing to do.
             }
             ast::struct_variant_kind(struct_def) => {
-                trans_struct_def(ccx, struct_def, path,
-                                 variant.node.id);
+                trans_struct_def(ccx, struct_def);
             }
         }
     }
@@ -2192,8 +2145,7 @@ pub fn trans_item(ccx: @CrateContext, item: &ast::item) {
         if !generics.is_type_parameterized() {
             let vi = ty::enum_variants(ccx.tcx, local_def(item.id));
             let mut i = 0;
-            trans_enum_def(ccx, enum_definition, item.id,
-                           path, vi, &mut i);
+            trans_enum_def(ccx, enum_definition, item.id, vi, &mut i);
         }
       }
       ast::item_const(_, expr) => consts::trans_const(ccx, expr, item.id),
@@ -2202,22 +2154,14 @@ pub fn trans_item(ccx: @CrateContext, item: &ast::item) {
       }
       ast::item_struct(struct_def, ref generics) => {
         if !generics.is_type_parameterized() {
-            trans_struct_def(ccx, struct_def, path, item.id);
+            trans_struct_def(ccx, struct_def);
         }
       }
       _ => {/* fall through */ }
     }
 }
 
-pub fn trans_struct_def(ccx: @CrateContext, struct_def: @ast::struct_def,
-                        path: @ast_map::path,
-                        id: ast::node_id) {
-    // Translate the destructor.
-    for struct_def.dtor.each |dtor| {
-        trans_struct_dtor(ccx, /*bad*/copy *path, &dtor.node.body,
-                         dtor.node.id, None, None, local_def(id));
-    };
-
+pub fn trans_struct_def(ccx: @CrateContext, struct_def: @ast::struct_def) {
     // If this is a tuple-like struct, translate the constructor.
     match struct_def.ctor_id {
         // We only need to translate a constructor if there are fields;
@@ -2451,49 +2395,6 @@ pub fn item_path(ccx: @CrateContext, i: @ast::item) -> path {
     vec::append(/*bad*/copy *base, ~[path_name(i.ident)])
 }
 
-/* If there's already a symbol for the dtor with <id> and substs <substs>,
-   return it; otherwise, create one and register it, returning it as well */
-pub fn get_dtor_symbol(ccx: @CrateContext,
-                       path: path,
-                       id: ast::node_id,
-                       substs: Option<@param_substs>)
-                    -> ~str {
-    let t = ty::node_id_to_type(ccx.tcx, id);
-    match ccx.item_symbols.find(&id) {
-        Some(s) => {
-            return /*bad*/copy *s;
-        }
-        None => { }
-    }
-
-    return if substs.is_none() {
-        let s = mangle_exported_name(
-            ccx,
-            vec::append(path, ~[path_name((ccx.names)(~"dtor"))]),
-            t);
-        // XXX: Bad copy, use `@str`?
-        ccx.item_symbols.insert(id, copy s);
-        s
-    } else {
-        // Monomorphizing, so just make a symbol, don't add
-        // this to item_symbols
-        match substs {
-            Some(ss) => {
-                let mono_ty = ty::subst_tps(ccx.tcx, ss.tys, ss.self_ty, t);
-                mangle_exported_name(
-                    ccx,
-                    vec::append(path,
-                                ~[path_name((ccx.names)(~"dtor"))]),
-                    mono_ty)
-            }
-            None => {
-                ccx.sess.bug(fmt!("get_dtor_symbol: not monomorphizing and \
-                                   couldn't find a symbol for dtor %?", path));
-            }
-        }
-    };
-}
-
 pub fn get_item_val(ccx: @CrateContext, id: ast::node_id) -> ValueRef {
     debug!("get_item_val(id=`%?`)", id);
     let tcx = ccx.tcx;
@@ -2501,13 +2402,13 @@ pub fn get_item_val(ccx: @CrateContext, id: ast::node_id) -> ValueRef {
       Some(&v) => v,
       None => {
         let mut exprt = false;
-        let val = match ccx.tcx.items.get_copy(&id) {
+        let val = match tcx.items.get_copy(&id) {
           ast_map::node_item(i, pth) => {
             let my_path = vec::append(/*bad*/copy *pth,
                                       ~[path_name(i.ident)]);
             match i.node {
               ast::item_const(_, expr) => {
-                let typ = ty::node_id_to_type(ccx.tcx, i.id);
+                let typ = ty::node_id_to_type(tcx, i.id);
                 let s = mangle_exported_name(ccx, my_path, typ);
                 // We need the translated value here, because for enums the
                 // LLVM type is not fully determined by the Rust type.
@@ -2566,7 +2467,7 @@ pub fn get_item_val(ccx: @CrateContext, id: ast::node_id) -> ValueRef {
                                 ni.attrs)
                 }
                 ast::foreign_item_const(*) => {
-                    let typ = ty::node_id_to_type(ccx.tcx, ni.id);
+                    let typ = ty::node_id_to_type(tcx, ni.id);
                     let ident = ccx.sess.parse_sess.interner.get(ni.ident);
                     let g = do str::as_c_str(*ident) |buf| {
                         unsafe {
@@ -2579,28 +2480,6 @@ pub fn get_item_val(ccx: @CrateContext, id: ast::node_id) -> ValueRef {
                 }
             }
           }
-          ast_map::node_dtor(_, dt, parent_id, pt) => {
-            /*
-                Don't just call register_fn, since we don't want to add
-                the implicit self argument automatically (we want to make sure
-                it has the right type)
-            */
-            // Want parent_id and not id, because id is the dtor's type
-            let class_ty = ty::lookup_item_type(tcx, parent_id).ty;
-            // This code shouldn't be reached if the class is generic
-            assert!(!ty::type_has_params(class_ty));
-            let lldty = T_fn(~[
-                    T_ptr(T_i8()),
-                    T_ptr(type_of(ccx, class_ty))
-                ],
-                T_nil());
-            let s = get_dtor_symbol(ccx, /*bad*/copy *pt, dt.node.id, None);
-
-            /* Make the declaration for the dtor */
-            let llfn = decl_internal_cdecl_fn(ccx.llmod, s, lldty);
-            lib::llvm::SetLinkage(llfn, lib::llvm::ExternalLinkage);
-            llfn
-          }
 
           ast_map::node_variant(ref v, enm, pth) => {
             let llfn;
@@ -2629,7 +2508,7 @@ pub fn get_item_val(ccx: @CrateContext, id: ast::node_id) -> ValueRef {
             // Only register the constructor if this is a tuple-like struct.
             match struct_def.ctor_id {
                 None => {
-                    ccx.tcx.sess.bug(~"attempt to register a constructor of \
+                    tcx.sess.bug(~"attempt to register a constructor of \
                                        a non-tuple-like struct")
                 }
                 Some(ctor_id) => {
@@ -3267,12 +3146,3 @@ pub fn trans_crate(sess: session::Session,
         return (llmod, link_meta);
     }
 }
-//
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
-//
diff --git a/src/librustc/middle/trans/build.rs b/src/librustc/middle/trans/build.rs
index a9ed80d1eaa..c3dc4f1e8eb 100644
--- a/src/librustc/middle/trans/build.rs
+++ b/src/librustc/middle/trans/build.rs
@@ -1086,13 +1086,3 @@ pub fn AtomicRMW(cx: block, op: AtomicBinOp,
         llvm::LLVMBuildAtomicRMW(B(cx), op, dst, src, order)
     }
 }
-
-//
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
-//
diff --git a/src/librustc/middle/trans/cabi.rs b/src/librustc/middle/trans/cabi.rs
index ed028d14bd6..d49e8e0969a 100644
--- a/src/librustc/middle/trans/cabi.rs
+++ b/src/librustc/middle/trans/cabi.rs
@@ -190,4 +190,3 @@ pub impl FnType {
         Store(bcx, llretval, llretptr);
     }
 }
-
diff --git a/src/librustc/middle/trans/callee.rs b/src/librustc/middle/trans/callee.rs
index 12f91fb8597..87322393ab9 100644
--- a/src/librustc/middle/trans/callee.rs
+++ b/src/librustc/middle/trans/callee.rs
@@ -351,9 +351,7 @@ pub fn trans_method_call(in_cx: block,
                                               origin)
                 }
                 None => {
-                    cx.tcx().sess.span_bug(call_ex.span,
-                                           ~"method call expr wasn't in \
-                                             method map")
+                    cx.tcx().sess.span_bug(call_ex.span, "method call expr wasn't in method map")
                 }
             }
         },
@@ -795,4 +793,3 @@ pub fn trans_arg_expr(bcx: block,
     debug!("--- trans_arg_expr passing %s", val_str(bcx.ccx().tn, val));
     return rslt(bcx, val);
 }
-
diff --git a/src/librustc/middle/trans/closure.rs b/src/librustc/middle/trans/closure.rs
index a2a1f3d8b72..5742463174f 100644
--- a/src/librustc/middle/trans/closure.rs
+++ b/src/librustc/middle/trans/closure.rs
@@ -599,4 +599,3 @@ pub fn make_opaque_cbox_free_glue(
         }
     }
 }
-
diff --git a/src/librustc/middle/trans/common.rs b/src/librustc/middle/trans/common.rs
index f8b75838b87..442b5d25c8b 100644
--- a/src/librustc/middle/trans/common.rs
+++ b/src/librustc/middle/trans/common.rs
@@ -1545,13 +1545,3 @@ pub fn filename_and_line_num_from_span(bcx: block,
 pub fn bool_to_i1(bcx: block, llval: ValueRef) -> ValueRef {
     build::ICmp(bcx, lib::llvm::IntNE, llval, C_bool(false))
 }
-
-//
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
-//
diff --git a/src/librustc/middle/trans/consts.rs b/src/librustc/middle/trans/consts.rs
index dd68670287b..48c5a96c8e7 100644
--- a/src/librustc/middle/trans/consts.rs
+++ b/src/librustc/middle/trans/consts.rs
@@ -58,8 +58,7 @@ pub fn const_lit(cx: @CrateContext, e: @ast::expr, lit: ast::lit)
           }
           _ => {
             cx.sess.span_bug(lit.span,
-                             ~"floating point literal doesn't have the right \
-                               type");
+                             "floating point literal doesn't have the right type");
           }
         }
       }
@@ -271,7 +270,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef {
                 if is_float { llvm::LLVMConstFMul(te1, te2) }
                 else        { llvm::LLVMConstMul(te1, te2) }
               }
-              ast::quot   => {
+              ast::div    => {
                 if is_float    { llvm::LLVMConstFDiv(te1, te2) }
                 else if signed { llvm::LLVMConstSDiv(te1, te2) }
                 else           { llvm::LLVMConstUDiv(te1, te2) }
@@ -282,7 +281,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef {
                 else           { llvm::LLVMConstURem(te1, te2) }
               }
               ast::and    |
-              ast::or     => cx.sess.span_unimpl(e.span, ~"binop logic"),
+              ast::or     => cx.sess.span_unimpl(e.span, "binop logic"),
               ast::bitxor => llvm::LLVMConstXor(te1, te2),
               ast::bitand => llvm::LLVMConstAnd(te1, te2),
               ast::bitor  => llvm::LLVMConstOr(te1, te2),
@@ -296,7 +295,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef {
               ast::le     |
               ast::ne     |
               ast::ge     |
-              ast::gt     => cx.sess.span_unimpl(e.span, ~"binop comparator")
+              ast::gt     => cx.sess.span_unimpl(e.span, "binop comparator")
             }
           }
           ast::expr_unary(u, e) => {
@@ -345,8 +344,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef {
                   const_eval::const_int(i) => i as u64,
                   const_eval::const_uint(u) => u,
                   _ => cx.sess.span_bug(index.span,
-                                        ~"index is not an integer-constant \
-                                          expression")
+                                        "index is not an integer-constant expression")
               };
               let (arr, len) = match ty::get(bt).sty {
                   ty::ty_evec(_, vstore) | ty::ty_estr(vstore) =>
@@ -364,12 +362,10 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef {
                                                unit_sz))
                       },
                       _ => cx.sess.span_bug(base.span,
-                                            ~"index-expr base must be \
-                                              fixed-size or slice")
+                                            "index-expr base must be fixed-size or slice")
                   },
                   _ =>  cx.sess.span_bug(base.span,
-                                         ~"index-expr base must be \
-                                           a vector or string type")
+                                         "index-expr base must be a vector or string type")
               };
 
               let len = llvm::LLVMConstIntGetZExtValue(len) as u64;
@@ -381,7 +377,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef {
                   // FIXME #3170: report this earlier on in the const-eval
                   // pass. Reporting here is a bit late.
                   cx.sess.span_err(e.span,
-                                   ~"const index-expr is out of bounds");
+                                   "const index-expr is out of bounds");
               }
               const_get_elt(cx, arr, [iv as c_uint])
           }
@@ -455,8 +451,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef {
                       match fs.find(|f| field_ty.ident == f.node.ident) {
                           Some(ref f) => const_expr(cx, (*f).node.expr),
                           None => {
-                              cx.tcx.sess.span_bug(
-                                  e.span, ~"missing struct field");
+                              cx.tcx.sess.span_bug(e.span, "missing struct field");
                           }
                       }
                   });
@@ -472,8 +467,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef {
               ast::expr_lit(ref lit) => {
                 match lit.node {
                   ast::lit_str(*) => { const_expr(cx, sub) }
-                  _ => { cx.sess.span_bug(e.span,
-                                          ~"bad const-slice lit") }
+                  _ => { cx.sess.span_bug(e.span, "bad const-slice lit") }
                 }
               }
               ast::expr_vec(ref es, ast::m_imm) => {
@@ -488,8 +482,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef {
                 let p = const_ptrcast(cx, gv, llunitty);
                 C_struct(~[p, sz])
               }
-              _ => cx.sess.span_bug(e.span,
-                                    ~"bad const-slice expr")
+              _ => cx.sess.span_bug(e.span, "bad const-slice expr")
             }
           }
           ast::expr_path(pth) => {
@@ -521,8 +514,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef {
                     C_null(llty)
                 }
                 _ => {
-                    cx.sess.span_bug(e.span, ~"expected a const, fn, \
-                                               struct, or variant def")
+                    cx.sess.span_bug(e.span, "expected a const, fn, struct, or variant def")
                 }
             }
           }
@@ -543,13 +535,12 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef {
                       adt::trans_const(cx, repr, vinfo.disr_val,
                                        args.map(|a| const_expr(cx, *a)))
                   }
-                  _ => cx.sess.span_bug(e.span, ~"expected a struct or \
-                                                  variant def")
+                  _ => cx.sess.span_bug(e.span, "expected a struct or variant def")
               }
           }
           ast::expr_paren(e) => { return const_expr(cx, e); }
           _ => cx.sess.span_bug(e.span,
-                ~"bad constant expression type in consts::const_expr")
+                  "bad constant expression type in consts::const_expr")
         };
     }
 }
diff --git a/src/librustc/middle/trans/controlflow.rs b/src/librustc/middle/trans/controlflow.rs
index b16b7732086..f1192488bdd 100644
--- a/src/librustc/middle/trans/controlflow.rs
+++ b/src/librustc/middle/trans/controlflow.rs
@@ -392,4 +392,3 @@ pub fn trans_fail_bounds_check(bcx: block, sp: span,
     Unreachable(bcx);
     return bcx;
 }
-
diff --git a/src/librustc/middle/trans/datum.rs b/src/librustc/middle/trans/datum.rs
index d4ca0f3c4be..c19650e3b68 100644
--- a/src/librustc/middle/trans/datum.rs
+++ b/src/librustc/middle/trans/datum.rs
@@ -696,8 +696,8 @@ pub impl Datum {
         match self.try_deref(bcx, expr.span, expr.id, derefs, false) {
             (Some(lvres), bcx) => DatumBlock { bcx: bcx, datum: lvres },
             (None, _) => {
-                bcx.ccx().sess.span_bug(
-                    expr.span, ~"Cannot deref this expression");
+                bcx.ccx().sess.span_bug(expr.span,
+                                        "Cannot deref this expression");
             }
         }
     }
@@ -817,4 +817,3 @@ pub impl DatumBlock {
         self.datum.to_str(self.ccx())
     }
 }
-
diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs
index 1571fd71152..1e5680aff38 100644
--- a/src/librustc/middle/trans/debuginfo.rs
+++ b/src/librustc/middle/trans/debuginfo.rs
@@ -756,7 +756,7 @@ fn create_ty(cx: @CrateContext, t: ty::t, span: span)
             }
         },
         ty::ty_enum(_did, ref _substs) => {
-            cx.sess.span_bug(span, ~"debuginfo for enum NYI")
+            cx.sess.span_bug(span, "debuginfo for enum NYI")
         }
         ty::ty_box(ref mt) | ty::ty_uniq(ref mt) => {
             let boxed = create_ty(cx, mt.ty, span);
@@ -782,7 +782,7 @@ fn create_ty(cx: @CrateContext, t: ty::t, span: span)
             create_pointer_type(cx, t, span, pointee)
         },
         ty::ty_rptr(ref _region, ref _mt) => {
-            cx.sess.span_bug(span, ~"debuginfo for rptr NYI")
+            cx.sess.span_bug(span, "debuginfo for rptr NYI")
         },
         ty::ty_bare_fn(ref barefnty) => {
             let inputs = do barefnty.sig.inputs.map |a| { a.ty };
@@ -790,10 +790,10 @@ fn create_ty(cx: @CrateContext, t: ty::t, span: span)
             create_fn_ty(cx, t, inputs, output, span)
         },
         ty::ty_closure(ref _closurety) => {
-            cx.sess.span_bug(span, ~"debuginfo for closure NYI")
+            cx.sess.span_bug(span, "debuginfo for closure NYI")
         },
         ty::ty_trait(_did, ref _substs, ref _vstore, _) => {
-            cx.sess.span_bug(span, ~"debuginfo for trait NYI")
+            cx.sess.span_bug(span, "debuginfo for trait NYI")
         },
         ty::ty_struct(did, ref substs) => {
             let fields = ty::struct_fields(cx.tcx, did, substs);
@@ -860,14 +860,12 @@ pub fn create_local_var(bcx: block, local: @ast::local)
     let llptr = match bcx.fcx.lllocals.find(&local.node.id) {
       option::Some(&local_mem(v)) => v,
       option::Some(_) => {
-        bcx.tcx().sess.span_bug(local.span, ~"local is bound to \
-                something weird");
+        bcx.tcx().sess.span_bug(local.span, "local is bound to something weird");
       }
       option::None => {
         match bcx.fcx.lllocals.get_copy(&local.node.pat.id) {
           local_imm(v) => v,
-          _ => bcx.tcx().sess.span_bug(local.span, ~"local is bound to \
-                                                     something weird")
+          _ => bcx.tcx().sess.span_bug(local.span, "local is bound to something weird")
         }
       }
     };
@@ -966,8 +964,7 @@ pub fn create_function(fcx: fn_ctxt) -> @Metadata<SubProgramMetadata> {
           ast::item_fn(ref decl, _, _, _, _) => {
             (item.ident, decl.output, item.id)
           }
-          _ => fcx.ccx.sess.span_bug(item.span, ~"create_function: item \
-                                                  bound to non-function")
+          _ => fcx.ccx.sess.span_bug(item.span, "create_function: item bound to non-function")
         }
       }
       ast_map::node_method(method, _, _) => {
@@ -979,15 +976,10 @@ pub fn create_function(fcx: fn_ctxt) -> @Metadata<SubProgramMetadata> {
             ((dbg_cx.names)(~"fn"), decl.output, expr.id)
           }
           _ => fcx.ccx.sess.span_bug(expr.span,
-                                     ~"create_function: \
-                                       expected an expr_fn_block here")
+                  "create_function: expected an expr_fn_block here")
         }
       }
-      ast_map::node_dtor(_, _, did, _) => {
-        ((dbg_cx.names)(~"dtor"), ast_util::dtor_ty(), did.node)
-      }
-      _ => fcx.ccx.sess.bug(~"create_function: unexpected \
-                              sort of node")
+      _ => fcx.ccx.sess.bug("create_function: unexpected sort of node")
     };
 
     debug!("%?", ident);
diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs
index d961c0705e4..6f1dbd8c2fe 100644
--- a/src/librustc/middle/trans/expr.rs
+++ b/src/librustc/middle/trans/expr.rs
@@ -693,7 +693,7 @@ fn trans_rvalue_dps_unadjusted(bcx: block, expr: @ast::expr,
                 }
                 _ => {
                     bcx.tcx().sess.span_bug(expr.span,
-                                            ~"expr_cast of non-trait");
+                                            "expr_cast of non-trait");
                 }
             }
         }
@@ -703,8 +703,7 @@ fn trans_rvalue_dps_unadjusted(bcx: block, expr: @ast::expr,
         _ => {
             bcx.tcx().sess.span_bug(
                 expr.span,
-                fmt!("trans_rvalue_dps_unadjusted reached \
-                      fall-through case: %?",
+                fmt!("trans_rvalue_dps_unadjusted reached fall-through case: %?",
                      expr.node));
         }
     }
@@ -1165,7 +1164,7 @@ fn trans_rec_or_struct(bcx: block,
                 }
                 None => {
                     tcx.sess.span_bug(field.span,
-                                      ~"Couldn't find field in struct type")
+                                      "Couldn't find field in struct type")
                 }
             }
         };
@@ -1397,7 +1396,7 @@ fn trans_eager_binop(bcx: block,
         if is_float { FMul(bcx, lhs, rhs) }
         else { Mul(bcx, lhs, rhs) }
       }
-      ast::quot => {
+      ast::div => {
         if is_float {
             FDiv(bcx, lhs, rhs)
         } else {
@@ -1440,7 +1439,7 @@ fn trans_eager_binop(bcx: block,
         } else {
             if !ty::type_is_scalar(rhs_t) {
                 bcx.tcx().sess.span_bug(binop_expr.span,
-                                        ~"non-scalar comparison");
+                                        "non-scalar comparison");
             }
             let cmpr = base::compare_scalar_types(bcx, lhs, rhs, rhs_t, op);
             bcx = cmpr.bcx;
@@ -1448,7 +1447,7 @@ fn trans_eager_binop(bcx: block,
         }
       }
       _ => {
-        bcx.tcx().sess.span_bug(binop_expr.span, ~"unexpected binop");
+        bcx.tcx().sess.span_bug(binop_expr.span, "unexpected binop");
       }
     };
 
diff --git a/src/librustc/middle/trans/foreign.rs b/src/librustc/middle/trans/foreign.rs
index f49a7fb0de4..21e29b9ad82 100644
--- a/src/librustc/middle/trans/foreign.rs
+++ b/src/librustc/middle/trans/foreign.rs
@@ -1080,7 +1080,7 @@ pub fn trans_intrinsic(ccx: @CrateContext,
         _ => {
             // Could we make this an enum rather than a string? does it get
             // checked earlier?
-            ccx.sess.span_bug(item.span, ~"unknown intrinsic");
+            ccx.sess.span_bug(item.span, "unknown intrinsic");
         }
     }
     build_return(bcx);
diff --git a/src/librustc/middle/trans/glue.rs b/src/librustc/middle/trans/glue.rs
index 4c5a17056b2..a35c40b8520 100644
--- a/src/librustc/middle/trans/glue.rs
+++ b/src/librustc/middle/trans/glue.rs
@@ -394,10 +394,15 @@ pub fn call_tydesc_glue(cx: block, v: ValueRef, t: ty::t, field: uint)
 
 pub fn make_visit_glue(bcx: block, v: ValueRef, t: ty::t) {
     let _icx = bcx.insn_ctxt("make_visit_glue");
-    let mut bcx = bcx;
-    let (visitor_trait, object_ty) = ty::visitor_object_ty(bcx.tcx());
-    let v = PointerCast(bcx, v, T_ptr(type_of::type_of(bcx.ccx(), object_ty)));
-    bcx = reflect::emit_calls_to_trait_visit_ty(bcx, t, v, visitor_trait.def_id);
+    let bcx = do with_scope(bcx, None, ~"visitor cleanup") |bcx| {
+        let mut bcx = bcx;
+        let (visitor_trait, object_ty) = ty::visitor_object_ty(bcx.tcx());
+        let v = PointerCast(bcx, v, T_ptr(type_of::type_of(bcx.ccx(), object_ty)));
+        bcx = reflect::emit_calls_to_trait_visit_ty(bcx, t, v, visitor_trait.def_id);
+        // The visitor is a boxed object and needs to be dropped
+        add_clean(bcx, v, object_ty);
+        bcx
+    };
     build_return(bcx);
 }
 
@@ -443,11 +448,8 @@ pub fn make_free_glue(bcx: block, v: ValueRef, t: ty::t) {
         // Call the dtor if there is one
         match ty::ty_dtor(bcx.tcx(), did) {
             ty::NoDtor => bcx,
-            ty::LegacyDtor(ref dt_id) => {
-                trans_struct_drop(bcx, t, v, *dt_id, did, substs, false)
-            }
             ty::TraitDtor(ref dt_id) => {
-                trans_struct_drop(bcx, t, v, *dt_id, did, substs, true)
+                trans_struct_drop(bcx, t, v, *dt_id, did, substs)
             }
         }
       }
@@ -461,8 +463,7 @@ pub fn trans_struct_drop(bcx: block,
                          v0: ValueRef,
                          dtor_did: ast::def_id,
                          class_did: ast::def_id,
-                         substs: &ty::substs,
-                         take_ref: bool)
+                         substs: &ty::substs)
                       -> block {
     let repr = adt::represent_type(bcx.ccx(), t);
     let drop_flag = adt::trans_drop_flag_ptr(bcx, repr, v0);
@@ -484,15 +485,10 @@ pub fn trans_struct_drop(bcx: block,
         // (self)
         assert!((params.len() == 2));
 
-        // If we need to take a reference to the class (because it's using
-        // the Drop trait), do so now.
-        let llval;
-        if take_ref {
-            llval = alloca(bcx, val_ty(v0));
-            Store(bcx, v0, llval);
-        } else {
-            llval = v0;
-        }
+        // Take a reference to the class (because it's using the Drop trait),
+        // do so now.
+        let llval = alloca(bcx, val_ty(v0));
+        Store(bcx, v0, llval);
 
         let self_arg = PointerCast(bcx, llval, params[1]);
         let args = ~[C_null(T_ptr(T_i8())), self_arg];
@@ -534,10 +530,7 @@ pub fn make_drop_glue(bcx: block, v0: ValueRef, t: ty::t) {
         let tcx = bcx.tcx();
         match ty::ty_dtor(tcx, did) {
           ty::TraitDtor(dtor) => {
-            trans_struct_drop(bcx, t, v0, dtor, did, substs, true)
-          }
-          ty::LegacyDtor(dtor) => {
-            trans_struct_drop(bcx, t, v0, dtor, did, substs, false)
+            trans_struct_drop(bcx, t, v0, dtor, did, substs)
           }
           ty::NoDtor => {
             // No dtor? Just the default case
@@ -549,12 +542,12 @@ pub fn make_drop_glue(bcx: block, v0: ValueRef, t: ty::t) {
         closure::make_closure_glue(bcx, v0, t, drop_ty)
       }
       ty::ty_trait(_, _, ty::BoxTraitStore, _) => {
-        let llbox = Load(bcx, GEPi(bcx, v0, [0u, 1u]));
+        let llbox = Load(bcx, GEPi(bcx, v0, [0u, abi::trt_field_box]));
         decr_refcnt_maybe_free(bcx, llbox, ty::mk_opaque_box(ccx.tcx))
       }
       ty::ty_trait(_, _, ty::UniqTraitStore, _) => {
-        let lluniquevalue = GEPi(bcx, v0, [0, 1]);
-        let lltydesc = Load(bcx, GEPi(bcx, v0, [0, 2]));
+        let lluniquevalue = GEPi(bcx, v0, [0, abi::trt_field_box]);
+        let lltydesc = Load(bcx, GEPi(bcx, v0, [0, abi::trt_field_tydesc]));
         call_tydesc_glue_full(bcx, lluniquevalue, lltydesc,
                               abi::tydesc_field_free_glue, None);
         bcx
@@ -613,13 +606,13 @@ pub fn make_take_glue(bcx: block, v: ValueRef, t: ty::t) {
         closure::make_closure_glue(bcx, v, t, take_ty)
       }
       ty::ty_trait(_, _, ty::BoxTraitStore, _) => {
-        let llbox = Load(bcx, GEPi(bcx, v, [0u, 1u]));
+        let llbox = Load(bcx, GEPi(bcx, v, [0u, abi::trt_field_box]));
         incr_refcnt_of_boxed(bcx, llbox);
         bcx
       }
       ty::ty_trait(_, _, ty::UniqTraitStore, _) => {
-        let llval = GEPi(bcx, v, [0, 1]);
-        let lltydesc = Load(bcx, GEPi(bcx, v, [0, 2]));
+        let llval = GEPi(bcx, v, [0, abi::trt_field_box]);
+        let lltydesc = Load(bcx, GEPi(bcx, v, [0, abi::trt_field_tydesc]));
         call_tydesc_glue_full(bcx, llval, lltydesc,
                               abi::tydesc_field_take_glue, None);
         bcx
diff --git a/src/librustc/middle/trans/inline.rs b/src/librustc/middle/trans/inline.rs
index 40b7a444a3e..e5c6244879d 100644
--- a/src/librustc/middle/trans/inline.rs
+++ b/src/librustc/middle/trans/inline.rs
@@ -60,75 +60,70 @@ pub fn maybe_instantiate_inline(ccx: @CrateContext, fn_id: ast::def_id,
             ccx.stats.n_inlines += 1;
             if translate { trans_item(ccx, item); }
             local_def(item.id)
-          }
-          csearch::found(ast::ii_foreign(item)) => {
-            ccx.external.insert(fn_id, Some(item.id));
-            local_def(item.id)
-          }
-          csearch::found_parent(parent_id, ast::ii_item(item)) => {
-            ccx.external.insert(parent_id, Some(item.id));
-            let mut my_id = 0;
-            match item.node {
-              ast::item_enum(_, _) => {
-                let vs_here = ty::enum_variants(ccx.tcx, local_def(item.id));
-                let vs_there = ty::enum_variants(ccx.tcx, parent_id);
-                for vec::each2(*vs_here, *vs_there) |here, there| {
-                    if there.id == fn_id { my_id = here.id.node; }
-                    ccx.external.insert(there.id, Some(here.id.node));
-                }
+        }
+        csearch::found(ast::ii_foreign(item)) => {
+          ccx.external.insert(fn_id, Some(item.id));
+          local_def(item.id)
+        }
+        csearch::found_parent(parent_id, ast::ii_item(item)) => {
+          ccx.external.insert(parent_id, Some(item.id));
+          let mut my_id = 0;
+          match item.node {
+            ast::item_enum(_, _) => {
+              let vs_here = ty::enum_variants(ccx.tcx, local_def(item.id));
+              let vs_there = ty::enum_variants(ccx.tcx, parent_id);
+              for vec::each2(*vs_here, *vs_there) |here, there| {
+                  if there.id == fn_id { my_id = here.id.node; }
+                  ccx.external.insert(there.id, Some(here.id.node));
               }
-              _ => ccx.sess.bug(~"maybe_instantiate_inline: item has a \
-                    non-enum parent")
             }
-            if translate { trans_item(ccx, item); }
-            local_def(my_id)
-          }
-          csearch::found_parent(_, _) => {
-              ccx.sess.bug(~"maybe_get_item_ast returned a found_parent \
-               with a non-item parent");
+            _ => ccx.sess.bug(~"maybe_instantiate_inline: item has a \
+                  non-enum parent")
           }
-          csearch::found(ast::ii_method(impl_did, mth)) => {
-            ccx.stats.n_inlines += 1;
-            ccx.external.insert(fn_id, Some(mth.id));
-            let impl_tpt = ty::lookup_item_type(ccx.tcx, impl_did);
-            let num_type_params =
-                impl_tpt.generics.type_param_defs.len() +
-                mth.generics.ty_params.len();
-            if translate && num_type_params == 0 {
-                let llfn = get_item_val(ccx, mth.id);
-                let path = vec::append(
-                    ty::item_path(ccx.tcx, impl_did),
-                    ~[path_name(mth.ident)]);
-                let self_kind = match mth.self_ty.node {
-                    ast::sty_static => no_self,
-                    _ => {
-                        let self_ty = ty::node_id_to_type(ccx.tcx,
-                                                          mth.self_id);
-                        debug!("calling inline trans_fn with self_ty %s",
-                               ty_to_str(ccx.tcx, self_ty));
-                        match mth.self_ty.node {
-                            ast::sty_value => impl_owned_self(self_ty),
-                            _ => impl_self(self_ty),
-                        }
-                    }
-                };
-                trans_fn(ccx,
-                         path,
-                         &mth.decl,
-                         &mth.body,
-                         llfn,
-                         self_kind,
-                         None,
-                         mth.id,
-                         Some(impl_did),
-                         []);
-            }
-            local_def(mth.id)
-          }
-          csearch::found(ast::ii_dtor(ref dtor, _, _, _)) => {
-              ccx.external.insert(fn_id, Some((*dtor).node.id));
-              local_def((*dtor).node.id)
+          if translate { trans_item(ccx, item); }
+          local_def(my_id)
+        }
+        csearch::found_parent(_, _) => {
+            ccx.sess.bug(~"maybe_get_item_ast returned a found_parent \
+             with a non-item parent");
+        }
+        csearch::found(ast::ii_method(impl_did, mth)) => {
+          ccx.stats.n_inlines += 1;
+          ccx.external.insert(fn_id, Some(mth.id));
+          let impl_tpt = ty::lookup_item_type(ccx.tcx, impl_did);
+          let num_type_params =
+              impl_tpt.generics.type_param_defs.len() +
+              mth.generics.ty_params.len();
+          if translate && num_type_params == 0 {
+              let llfn = get_item_val(ccx, mth.id);
+              let path = vec::append(
+                  ty::item_path(ccx.tcx, impl_did),
+                  ~[path_name(mth.ident)]);
+              let self_kind = match mth.self_ty.node {
+                  ast::sty_static => no_self,
+                  _ => {
+                      let self_ty = ty::node_id_to_type(ccx.tcx,
+                                                        mth.self_id);
+                      debug!("calling inline trans_fn with self_ty %s",
+                             ty_to_str(ccx.tcx, self_ty));
+                      match mth.self_ty.node {
+                          ast::sty_value => impl_owned_self(self_ty),
+                          _ => impl_self(self_ty),
+                      }
+                  }
+              };
+              trans_fn(ccx,
+                       path,
+                       &mth.decl,
+                       &mth.body,
+                       llfn,
+                       self_kind,
+                       None,
+                       mth.id,
+                       Some(impl_did),
+                       []);
           }
+          local_def(mth.id)
+        }
     };
 }
-
diff --git a/src/librustc/middle/trans/machine.rs b/src/librustc/middle/trans/machine.rs
index 73b79fa37e2..ff9faa24376 100644
--- a/src/librustc/middle/trans/machine.rs
+++ b/src/librustc/middle/trans/machine.rs
@@ -153,4 +153,3 @@ pub fn static_size_of_enum(cx: @CrateContext, t: ty::t) -> uint {
         _ => cx.sess.bug(~"static_size_of_enum called on non-enum")
     }
 }
-
diff --git a/src/librustc/middle/trans/macros.rs b/src/librustc/middle/trans/macros.rs
index 14ed7692661..43cc66c5568 100644
--- a/src/librustc/middle/trans/macros.rs
+++ b/src/librustc/middle/trans/macros.rs
@@ -51,4 +51,3 @@ macro_rules! trace(
         }
     )
 )
-
diff --git a/src/librustc/middle/trans/meth.rs b/src/librustc/middle/trans/meth.rs
index 693947d7e99..934a995b588 100644
--- a/src/librustc/middle/trans/meth.rs
+++ b/src/librustc/middle/trans/meth.rs
@@ -642,14 +642,15 @@ pub fn trans_trait_callee_from_llval(bcx: block,
            val_str(bcx.ccx().tn, llpair));
     let llvtable = Load(bcx,
                       PointerCast(bcx,
-                                  GEPi(bcx, llpair, [0u, 0u]),
+                                  GEPi(bcx, llpair,
+                                       [0u, abi::trt_field_vtable]),
                                   T_ptr(T_ptr(T_vtable()))));
 
     // Load the box from the @Trait pair and GEP over the box header if
     // necessary:
     let mut llself;
     debug!("(translating trait callee) loading second index from pair");
-    let llbox = Load(bcx, GEPi(bcx, llpair, [0u, 1u]));
+    let llbox = Load(bcx, GEPi(bcx, llpair, [0u, abi::trt_field_box]));
 
     // Munge `llself` appropriately for the type of `self` in the method.
     let self_mode;
@@ -850,27 +851,30 @@ pub fn trans_trait_cast(bcx: block,
 
     match store {
         ty::RegionTraitStore(_) | ty::BoxTraitStore => {
-            let mut llboxdest = GEPi(bcx, lldest, [0u, 1u]);
-            // Just store the pointer into the pair.
+            let mut llboxdest = GEPi(bcx, lldest, [0u, abi::trt_field_box]);
+            // Just store the pointer into the pair. (Region/borrowed
+            // and boxed trait objects are represented as pairs, and
+            // have no type descriptor field.)
             llboxdest = PointerCast(bcx,
                                     llboxdest,
                                     T_ptr(type_of(bcx.ccx(), v_ty)));
             bcx = expr::trans_into(bcx, val, SaveIn(llboxdest));
         }
         ty::UniqTraitStore => {
-            // Translate the uniquely-owned value into the second element of
-            // the triple. (The first element is the vtable.)
-            let mut llvaldest = GEPi(bcx, lldest, [0, 1]);
+            // Translate the uniquely-owned value in the
+            // triple. (Unique trait objects are represented as
+            // triples.)
+            let mut llvaldest = GEPi(bcx, lldest, [0, abi::trt_field_box]);
             llvaldest = PointerCast(bcx,
                                     llvaldest,
                                     T_ptr(type_of(bcx.ccx(), v_ty)));
             bcx = expr::trans_into(bcx, val, SaveIn(llvaldest));
 
-            // Get the type descriptor of the wrapped value and store it into
-            // the third element of the triple as well.
+            // Get the type descriptor of the wrapped value and store
+            // it in the triple as well.
             let tydesc = get_tydesc(bcx.ccx(), v_ty);
             glue::lazily_emit_all_tydesc_glue(bcx.ccx(), tydesc);
-            let lltydescdest = GEPi(bcx, lldest, [0, 2]);
+            let lltydescdest = GEPi(bcx, lldest, [0, abi::trt_field_tydesc]);
             Store(bcx, tydesc.tydesc, lltydescdest);
         }
     }
@@ -880,7 +884,7 @@ pub fn trans_trait_cast(bcx: block,
     let orig = resolve_vtable_in_fn_ctxt(bcx.fcx, orig);
     let vtable = get_vtable(bcx.ccx(), orig);
     Store(bcx, vtable, PointerCast(bcx,
-                                   GEPi(bcx, lldest, [0u, 0u]),
+                                   GEPi(bcx, lldest, [0u, abi::trt_field_vtable]),
                                    T_ptr(val_ty(vtable))));
 
     bcx
diff --git a/src/librustc/middle/trans/monomorphize.rs b/src/librustc/middle/trans/monomorphize.rs
index e1b81933e68..6e250641869 100644
--- a/src/librustc/middle/trans/monomorphize.rs
+++ b/src/librustc/middle/trans/monomorphize.rs
@@ -13,7 +13,7 @@ use driver::session;
 use lib::llvm::ValueRef;
 use middle::trans::base::{get_insn_ctxt};
 use middle::trans::base::{set_inline_hint_if_appr, set_inline_hint};
-use middle::trans::base::{trans_enum_variant, trans_struct_dtor};
+use middle::trans::base::{trans_enum_variant};
 use middle::trans::base::{trans_fn, decl_internal_cdecl_fn};
 use middle::trans::base::{get_item_val, no_self};
 use middle::trans::base;
@@ -35,7 +35,6 @@ use syntax::ast_map;
 use syntax::ast_map::path_name;
 use syntax::ast_util::local_def;
 use syntax::opt_vec;
-use syntax::parse::token::special_idents;
 use syntax::abi::AbiSet;
 
 pub fn monomorphic_fn(ccx: @CrateContext,
@@ -118,8 +117,6 @@ pub fn monomorphic_fn(ccx: @CrateContext,
         // Foreign externs don't have to be monomorphized.
         return (get_item_val(ccx, fn_id.node), true);
       }
-      ast_map::node_dtor(_, dtor, _, pt) =>
-          (pt, special_idents::dtor, dtor.span),
       ast_map::node_trait_method(@ast::provided(m), _, pt) => {
         (pt, m.ident, m.span)
       }
@@ -168,7 +165,7 @@ pub fn monomorphic_fn(ccx: @CrateContext,
     // causing an infinite expansion.
     if depth > 30 {
         ccx.sess.span_fatal(
-            span, ~"overly deep expansion of inlined function");
+            span, "overly deep expansion of inlined function");
     }
     ccx.monomorphizing.insert(fn_id, depth + 1);
 
@@ -248,16 +245,6 @@ pub fn monomorphic_fn(ccx: @CrateContext,
         meth::trans_method(ccx, pt, mth, psubsts, None, d, impl_did);
         d
       }
-      ast_map::node_dtor(_, dtor, _, pt) => {
-        let parent_id = match ty::ty_to_def_id(ty::node_id_to_type(ccx.tcx,
-                                              dtor.node.self_id)) {
-                Some(did) => did,
-                None      => ccx.sess.span_bug(dtor.span, ~"Bad self ty in \
-                                                            dtor")
-        };
-        trans_struct_dtor(ccx, /*bad*/copy *pt, &dtor.node.body,
-          dtor.node.id, psubsts, Some(hash_id), parent_id)
-      }
       ast_map::node_trait_method(@ast::provided(mth), _, pt) => {
         let d = mk_lldecl();
         set_inline_hint_if_appr(/*bad*/copy mth.attrs, d);
diff --git a/src/librustc/middle/trans/reachable.rs b/src/librustc/middle/trans/reachable.rs
index 058ce638030..4d5a7a72a8d 100644
--- a/src/librustc/middle/trans/reachable.rs
+++ b/src/librustc/middle/trans/reachable.rs
@@ -134,22 +134,11 @@ fn traverse_public_item(cx: @mut ctx, item: @item) {
             }
         }
       }
-      item_struct(ref struct_def, ref generics) => {
+      item_struct(ref struct_def, _) => {
         for struct_def.ctor_id.each |&ctor_id| {
             let cx = &mut *cx; // NOTE reborrow @mut
             cx.rmap.insert(ctor_id);
         }
-        for struct_def.dtor.each |dtor| {
-            {
-                let cx = &mut *cx; // NOTE reborrow @mut
-                cx.rmap.insert(dtor.node.id);
-            }
-            if generics.ty_params.len() > 0u ||
-                attr::find_inline_attr(dtor.node.attrs) != attr::ia_none
-            {
-                traverse_inline_body(cx, &dtor.node.body);
-            }
-        }
       }
       item_ty(t, _) => {
         traverse_ty(t, cx,
@@ -193,11 +182,13 @@ fn traverse_inline_body(cx: @mut ctx, body: &blk) {
           expr_path(_) => {
             match cx.tcx.def_map.find(&e.id) {
                 Some(&d) => {
-                  traverse_def_id(cx, def_id_of_def(d));
+                    traverse_def_id(cx, def_id_of_def(d));
                 }
-                None      => cx.tcx.sess.span_bug(e.span, fmt!("Unbound node \
-                  id %? while traversing %s", e.id,
-                  expr_to_str(e, cx.tcx.sess.intr())))
+                None => cx.tcx.sess.span_bug(
+                    e.span,
+                    fmt!("Unbound node id %? while traversing %s",
+                         e.id,
+                         expr_to_str(e, cx.tcx.sess.intr())))
             }
           }
           expr_field(_, _, _) => {
@@ -254,9 +245,6 @@ fn traverse_all_resources_and_impls(cx: @mut ctx, crate_mod: &_mod) {
             visit_item: |i, cx, v| {
                 visit::visit_item(i, cx, v);
                 match i.node {
-                    item_struct(sdef, _) if sdef.dtor.is_some() => {
-                        traverse_public_item(cx, i);
-                    }
                     item_impl(*) => {
                         traverse_public_item(cx, i);
                     }
@@ -266,4 +254,3 @@ fn traverse_all_resources_and_impls(cx: @mut ctx, crate_mod: &_mod) {
             ..*visit::default_visitor()
         }));
 }
-
diff --git a/src/librustc/middle/trans/reflect.rs b/src/librustc/middle/trans/reflect.rs
index 5f77173f563..9e1f10467e3 100644
--- a/src/librustc/middle/trans/reflect.rs
+++ b/src/librustc/middle/trans/reflect.rs
@@ -405,4 +405,3 @@ pub fn ast_purity_constant(purity: ast::purity) -> uint {
         ast::extern_fn => 3u
     }
 }
-
diff --git a/src/librustc/middle/trans/shape.rs b/src/librustc/middle/trans/shape.rs
index 08337c918b0..6ff9e1cfc57 100644
--- a/src/librustc/middle/trans/shape.rs
+++ b/src/librustc/middle/trans/shape.rs
@@ -74,4 +74,3 @@ pub fn add_substr(dest: &mut ~[u8], src: ~[u8]) {
     add_u16(&mut *dest, vec::len(src) as u16);
     *dest += src;
 }
-
diff --git a/src/librustc/middle/trans/tvec.rs b/src/librustc/middle/trans/tvec.rs
index 30a7648e7ea..e8075c1f2ad 100644
--- a/src/librustc/middle/trans/tvec.rs
+++ b/src/librustc/middle/trans/tvec.rs
@@ -469,7 +469,7 @@ pub fn write_content(bcx: block,
         }
         _ => {
             bcx.tcx().sess.span_bug(content_expr.span,
-                                    ~"Unexpected evec content");
+                                    "Unexpected evec content");
         }
     }
 }
@@ -503,7 +503,7 @@ pub fn elements_required(bcx: block, content_expr: @ast::expr) -> uint {
             ty::eval_repeat_count(bcx.tcx(), count_expr)
         }
         _ => bcx.tcx().sess.span_bug(content_expr.span,
-                                     ~"Unexpected evec content")
+                                     "Unexpected evec content")
     }
 }
 
@@ -594,13 +594,3 @@ pub fn iter_vec_unboxed(bcx: block, body_ptr: ValueRef, vec_ty: ty::t,
     let dataptr = get_dataptr(bcx, body_ptr);
     return iter_vec_raw(bcx, dataptr, vec_ty, fill, f);
 }
-
-//
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
-//
diff --git a/src/librustc/middle/trans/type_use.rs b/src/librustc/middle/trans/type_use.rs
index 46cc99e71cc..94ef33e45bb 100644
--- a/src/librustc/middle/trans/type_use.rs
+++ b/src/librustc/middle/trans/type_use.rs
@@ -157,9 +157,6 @@ pub fn type_uses_for(ccx: @CrateContext, fn_id: def_id, n_tps: uint)
             for uint::range(0u, n_tps) |n| { cx.uses[n] |= flags;}
         }
       }
-      ast_map::node_dtor(_, ref dtor, _, _) => {
-        handle_body(cx, &dtor.node.body);
-      }
       ast_map::node_struct_ctor(*) => {
         // Similarly to node_variant, this monomorphized function just uses
         // the representations of all of its type parameters.
@@ -391,4 +388,3 @@ pub fn handle_body(cx: Context, body: &blk) {
     });
     (v.visit_block)(body, cx, v);
 }
-
diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs
index eac73ce1a2e..03704afdb86 100644
--- a/src/librustc/middle/ty.rs
+++ b/src/librustc/middle/ty.rs
@@ -33,7 +33,7 @@ use core::to_bytes;
 use core::hashmap::{HashMap, HashSet};
 use std::smallintmap::SmallIntMap;
 use syntax::ast::*;
-use syntax::ast_util::{is_local, local_def};
+use syntax::ast_util::is_local;
 use syntax::ast_util;
 use syntax::attr;
 use syntax::codemap::span;
@@ -1257,16 +1257,6 @@ pub fn mk_opaque_closure_ptr(cx: ctxt, sigil: ast::Sigil) -> t {
 
 pub fn mk_opaque_box(cx: ctxt) -> t { mk_t(cx, ty_opaque_box) }
 
-// Converts s to its machine type equivalent
-pub fn mach_sty(cfg: @session::config, t: t) -> sty {
-    match get(t).sty {
-      ty_int(ast::ty_i) => ty_int(cfg.int_type),
-      ty_uint(ast::ty_u) => ty_uint(cfg.uint_type),
-      ty_float(ast::ty_f) => ty_float(cfg.float_type),
-      ref s => (/*bad*/copy *s)
-    }
-}
-
 pub fn walk_ty(ty: t, f: &fn(t)) {
     maybe_walk_ty(ty, |t| { f(t); true });
 }
@@ -1829,15 +1819,6 @@ pub impl TypeContents {
         if cx.vecs_implicitly_copyable {base} else {base + TC_OWNED_VEC}
     }
 
-    fn is_safe_for_default_mode(&self, cx: ctxt) -> bool {
-        !self.intersects(TypeContents::nondefault_mode(cx))
-    }
-
-    fn nondefault_mode(cx: ctxt) -> TypeContents {
-        let tc = TypeContents::nonimplicitly_copyable(cx);
-        tc + TC_BIG + TC_OWNED_VEC // disregard cx.vecs_implicitly_copyable
-    }
-
     fn needs_drop(&self, cx: ctxt) -> bool {
         let tc = TC_MANAGED + TC_DTOR + TypeContents::owned(cx);
         self.intersects(tc)
@@ -1897,9 +1878,6 @@ static TC_MUTABLE: TypeContents =          TypeContents{bits:0b000010000000};
 /// Mutable content, whether owned or by ref
 static TC_ONCE_CLOSURE: TypeContents =     TypeContents{bits:0b000100000000};
 
-/// Something we estimate to be "big"
-static TC_BIG: TypeContents =              TypeContents{bits:0b001000000000};
-
 /// An enum with no variants.
 static TC_EMPTY_ENUM: TypeContents =       TypeContents{bits:0b010000000000};
 
@@ -2120,10 +2098,6 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents {
             }
         };
 
-        if type_size(cx, ty) > 4 {
-            result = result + TC_BIG;
-        }
-
         cache.insert(ty_id, result);
         return result;
     }
@@ -2199,68 +2173,6 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents {
         debug!("result = %s", r.to_str());
         return r;
     }
-
-    /// gives a rough estimate of how much space it takes to represent
-    /// an instance of `ty`.  Used for the mode transition.
-    fn type_size(cx: ctxt, ty: t) -> uint {
-        match get(ty).sty {
-          ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) |
-          ty_ptr(_) | ty_box(_) | ty_uniq(_) | ty_estr(vstore_uniq) |
-          ty_trait(*) | ty_rptr(*) | ty_evec(_, vstore_uniq) |
-          ty_evec(_, vstore_box) | ty_estr(vstore_box) => {
-            1
-          }
-
-          ty_evec(_, vstore_slice(_)) |
-          ty_estr(vstore_slice(_)) |
-          ty_bare_fn(*) |
-          ty_closure(*) => {
-            2
-          }
-
-          ty_evec(t, vstore_fixed(n)) => {
-            type_size(cx, t.ty) * n
-          }
-
-          ty_estr(vstore_fixed(n)) => {
-            n
-          }
-
-          ty_struct(did, ref substs) => {
-            let flds = struct_fields(cx, did, substs);
-            flds.foldl(0, |s, f| *s + type_size(cx, f.mt.ty))
-          }
-
-          ty_tup(ref tys) => {
-            tys.foldl(0, |s, t| *s + type_size(cx, *t))
-          }
-
-          ty_enum(did, ref substs) => {
-            let variants = substd_enum_variants(cx, did, substs);
-            variants.foldl( // find max size of any variant
-                0,
-                |m, v| uint::max(
-                    *m,
-                    // find size of this variant:
-                    v.args.foldl(0, |s, a| *s + type_size(cx, *a))))
-          }
-
-          ty_param(_) | ty_self(_) => {
-            1
-          }
-
-          ty_infer(_) => {
-            cx.sess.bug(~"Asked to compute kind of a type variable");
-          }
-          ty_type => 1,
-          ty_opaque_closure_ptr(_) => 1,
-          ty_opaque_box => 1,
-          ty_unboxed_vec(_) => 10,
-          ty_err => {
-            cx.sess.bug(~"Asked to compute kind of fictitious type");
-          }
-        }
-    }
 }
 
 pub fn type_moves_by_default(cx: ctxt, ty: t) -> bool {
@@ -2520,12 +2432,15 @@ pub fn type_is_enum(ty: t) -> bool {
 // constructors
 pub fn type_is_c_like_enum(cx: ctxt, ty: t) -> bool {
     match get(ty).sty {
-      ty_enum(did, _) => {
-        let variants = enum_variants(cx, did);
-        let some_n_ary = vec::any(*variants, |v| vec::len(v.args) > 0u);
-        return !some_n_ary;
-      }
-      _ => return false
+        ty_enum(did, _) => {
+            let variants = enum_variants(cx, did);
+            if variants.len() == 0 {
+                false
+            } else {
+                variants.all(|v| v.args.len() == 0)
+            }
+        }
+        _ => false
     }
 }
 
@@ -3294,7 +3209,7 @@ pub fn expr_kind(tcx: ctxt,
         ast::expr_mac(*) => {
             tcx.sess.span_bug(
                 expr.span,
-                ~"macro expression remains after expansion");
+                "macro expression remains after expansion");
         }
     }
 }
@@ -3761,7 +3676,6 @@ pub fn item_path_str(cx: ctxt, id: ast::def_id) -> ~str {
 
 pub enum DtorKind {
     NoDtor,
-    LegacyDtor(def_id),
     TraitDtor(def_id)
 }
 
@@ -3781,28 +3695,8 @@ pub impl DtorKind {
    Otherwise return none. */
 pub fn ty_dtor(cx: ctxt, struct_id: def_id) -> DtorKind {
     match cx.destructor_for_type.find(&struct_id) {
-        Some(&method_def_id) => return TraitDtor(method_def_id),
-        None => {}  // Continue.
-    }
-
-    if is_local(struct_id) {
-       match cx.items.find(&struct_id.node) {
-           Some(&ast_map::node_item(@ast::item {
-               node: ast::item_struct(@ast::struct_def { dtor: Some(ref dtor),
-                                                         _ },
-                                      _),
-               _
-           }, _)) =>
-               LegacyDtor(local_def((*dtor).node.id)),
-           _ =>
-               NoDtor
-       }
-    }
-    else {
-      match csearch::struct_dtor(cx.sess.cstore, struct_id) {
+        Some(&method_def_id) => TraitDtor(method_def_id),
         None => NoDtor,
-        Some(did) => LegacyDtor(did),
-      }
     }
 }
 
@@ -3852,11 +3746,6 @@ pub fn item_path(cx: ctxt, id: ast::def_id) -> ast_map::path {
                             ast_map::path_name((*variant).node.name))
           }
 
-          ast_map::node_dtor(_, _, _, path) => {
-            vec::append_one(/*bad*/copy *path, ast_map::path_name(
-                syntax::parse::token::special_idents::literally_dtor))
-          }
-
           ast_map::node_struct_ctor(_, item, path) => {
             vec::append_one(/*bad*/copy *path, ast_map::path_name(item.ident))
           }
@@ -4167,7 +4056,7 @@ pub fn is_binopable(_cx: ctxt, ty: t, op: ast::binop) -> bool {
           ast::add => opcat_add,
           ast::subtract => opcat_sub,
           ast::mul => opcat_mult,
-          ast::quot => opcat_mult,
+          ast::div => opcat_mult,
           ast::rem => opcat_mult,
           ast::and => opcat_logic,
           ast::or => opcat_logic,
@@ -4300,27 +4189,27 @@ pub fn eval_repeat_count(tcx: ctxt, count_expr: @ast::expr) -> uint {
         const_eval::const_uint(count) => return count as uint,
         const_eval::const_float(count) => {
             tcx.sess.span_err(count_expr.span,
-                              ~"expected signed or unsigned integer for \
-                                repeat count but found float");
+                              "expected signed or unsigned integer for \
+                               repeat count but found float");
             return count as uint;
         }
         const_eval::const_str(_) => {
             tcx.sess.span_err(count_expr.span,
-                              ~"expected signed or unsigned integer for \
-                                repeat count but found string");
+                              "expected signed or unsigned integer for \
+                               repeat count but found string");
             return 0;
         }
         const_eval::const_bool(_) => {
             tcx.sess.span_err(count_expr.span,
-                              ~"expected signed or unsigned integer for \
-                                repeat count but found boolean");
+                              "expected signed or unsigned integer for \
+                               repeat count but found boolean");
             return 0;
         }
       },
       Err(*) => {
         tcx.sess.span_err(count_expr.span,
-                          ~"expected constant integer for repeat count \
-                            but found variable");
+                          "expected constant integer for repeat count \
+                           but found variable");
         return 0;
       }
     }
@@ -4428,11 +4317,3 @@ pub fn visitor_object_ty(tcx: ctxt) -> (@TraitRef, t) {
     (trait_ref,
      mk_trait(tcx, trait_ref.def_id, copy trait_ref.substs, BoxTraitStore, ast::m_imm))
 }
-
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
diff --git a/src/librustc/middle/typeck/astconv.rs b/src/librustc/middle/typeck/astconv.rs
index ffaa6d46d33..7ef77646f52 100644
--- a/src/librustc/middle/typeck/astconv.rs
+++ b/src/librustc/middle/typeck/astconv.rs
@@ -291,10 +291,8 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:region_scope + Copy + Durable>(
                             ty::vstore_fixed(*) => {
                                 tcx.sess.span_err(
                                     path.span,
-                                    ~"@trait, ~trait or &trait \
-                                      are the only supported \
-                                      forms of casting-to-\
-                                      trait");
+                                    "@trait, ~trait or &trait are the only supported \
+                                     forms of casting-to-trait");
                                 ty::BoxTraitStore
                             }
                         };
@@ -321,7 +319,7 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:region_scope + Copy + Durable>(
             if path.types.len() > 0u {
                 tcx.sess.span_err(
                     path.span,
-                    ~"type parameters are not allowed on this type");
+                    "type parameters are not allowed on this type");
             }
         }
 
@@ -329,7 +327,7 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:region_scope + Copy + Durable>(
             if path.rp.is_some() {
                 tcx.sess.span_err(
                     path.span,
-                    ~"region parameters are not allowed on this type");
+                    "region parameters are not allowed on this type");
             }
         }
     }
@@ -339,9 +337,8 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:region_scope + Copy + Durable>(
     match tcx.ast_ty_to_ty_cache.find(&ast_ty.id) {
       Some(&ty::atttce_resolved(ty)) => return ty,
       Some(&ty::atttce_unresolved) => {
-        tcx.sess.span_fatal(ast_ty.span, ~"illegal recursive type; \
-                                          insert an enum in the cycle, \
-                                          if this is desired");
+        tcx.sess.span_fatal(ast_ty.span, "illegal recursive type; \
+                                          insert an enum in the cycle, if this is desired");
       }
       None => { /* go on */ }
     }
@@ -359,11 +356,9 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:region_scope + Copy + Durable>(
                    |tmt| ty::mk_uniq(tcx, tmt))
       }
       ast::ty_vec(ref mt) => {
-        tcx.sess.span_err(ast_ty.span,
-                          ~"bare `[]` is not a type");
+        tcx.sess.span_err(ast_ty.span, "bare `[]` is not a type");
         // return /something/ so they can at least get more errors
-        ty::mk_evec(tcx, ast_mt_to_mt(self, rscope, mt),
-                    ty::vstore_uniq)
+        ty::mk_evec(tcx, ast_mt_to_mt(self, rscope, mt), ty::vstore_uniq)
       }
       ast::ty_ptr(ref mt) => {
         ty::mk_ptr(tcx, ast_mt_to_mt(self, rscope, mt))
@@ -434,7 +429,7 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:region_scope + Copy + Durable>(
               }
               ast::ty_str => {
                 tcx.sess.span_err(ast_ty.span,
-                                  ~"bare `str` is not a type");
+                                  "bare `str` is not a type");
                 // return /something/ so they can at least get more errors
                 ty::mk_estr(tcx, ty::vstore_uniq)
               }
@@ -454,7 +449,7 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:region_scope + Copy + Durable>(
           }
           _ => {
             tcx.sess.span_fatal(ast_ty.span,
-                                ~"found type name used as a variable");
+                                "found type name used as a variable");
           }
         }
       }
@@ -470,7 +465,7 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:region_scope + Copy + Durable>(
                             ty::vstore_fixed(i as uint)),
               _ => {
                 tcx.sess.span_fatal(
-                    ast_ty.span, ~"expected constant expr for vector length");
+                    ast_ty.span, "expected constant expr for vector length");
               }
             }
           }
@@ -489,11 +484,11 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:region_scope + Copy + Durable>(
         // routine.
         self.tcx().sess.span_bug(
             ast_ty.span,
-            ~"found `ty_infer` in unexpected place");
+            "found `ty_infer` in unexpected place");
       }
       ast::ty_mac(_) => {
         tcx.sess.span_bug(ast_ty.span,
-                          ~"found `ty_mac` in unexpected place");
+                          "found `ty_mac` in unexpected place");
       }
     };
 
diff --git a/src/librustc/middle/typeck/check/_match.rs b/src/librustc/middle/typeck/check/_match.rs
index a3bf1a5ef52..40c5df7b768 100644
--- a/src/librustc/middle/typeck/check/_match.rs
+++ b/src/librustc/middle/typeck/check/_match.rs
@@ -114,36 +114,52 @@ pub fn check_pat_variant(pcx: &pat_ctxt, pat: @ast::pat, path: @ast::Path,
         ty::ty_enum(_, ref expected_substs) => {
             // Lookup the enum and variant def ids:
             let v_def = lookup_def(pcx.fcx, pat.span, pat.id);
-            let (enm, var) = ast_util::variant_def_ids(v_def);
-
-            // Assign the pattern the type of the *enum*, not the variant.
-            let enum_tpt = ty::lookup_item_type(tcx, enm);
-            instantiate_path(pcx.fcx, path, enum_tpt, pat.span, pat.id);
-
-            // check that the type of the value being matched is a subtype
-            // of the type of the pattern:
-            let pat_ty = fcx.node_ty(pat.id);
-            demand::subtype(fcx, pat.span, expected, pat_ty);
-
-            // Get the expected types of the arguments.
-            arg_types = {
-                let vinfo =
-                    ty::enum_variant_with_id(tcx, enm, var);
-                let var_tpt = ty::lookup_item_type(tcx, var);
-                vinfo.args.map(|t| {
-                    if var_tpt.generics.type_param_defs.len() ==
-                        expected_substs.tps.len()
-                    {
-                        ty::subst(tcx, expected_substs, *t)
-                    }
-                    else {
-                        *t // In this case, an error was already signaled
-                           // anyway
-                    }
-                })
-            };
-
-            kind_name = "variant";
+            match ast_util::variant_def_ids(v_def) {
+                Some((enm, var)) => {
+                    // Assign the pattern the type of the *enum*, not the variant.
+                    let enum_tpt = ty::lookup_item_type(tcx, enm);
+                    instantiate_path(pcx.fcx, path, enum_tpt, pat.span, pat.id);
+
+                    // check that the type of the value being matched is a subtype
+                    // of the type of the pattern:
+                    let pat_ty = fcx.node_ty(pat.id);
+                    demand::subtype(fcx, pat.span, expected, pat_ty);
+
+                    // Get the expected types of the arguments.
+                    arg_types = {
+                        let vinfo =
+                            ty::enum_variant_with_id(tcx, enm, var);
+                        let var_tpt = ty::lookup_item_type(tcx, var);
+                        vinfo.args.map(|t| {
+                            if var_tpt.generics.type_param_defs.len() ==
+                                expected_substs.tps.len()
+                            {
+                                ty::subst(tcx, expected_substs, *t)
+                            }
+                            else {
+                                *t // In this case, an error was already signaled
+                                    // anyway
+                            }
+                        })
+                    };
+
+                    kind_name = "variant";
+                }
+                None => {
+                    let resolved_expected =
+                        fcx.infcx().ty_to_str(fcx.infcx().resolve_type_vars_if_possible(expected));
+                    fcx.infcx().type_error_message_str(pat.span,
+                                                       |actual| {
+                        fmt!("mismatched types: expected `%s` but found %s",
+                             resolved_expected, actual)},
+                             ~"a structure pattern",
+                             None);
+                    fcx.write_error(pat.id);
+                    kind_name = "[error]";
+                    arg_types = (copy subpats).get_or_default(~[]).map(|_|
+                                                                       ty::mk_err());
+                }
+            }
         }
         ty::ty_struct(struct_def_id, ref expected_substs) => {
             // Lookup the struct ctor def id
@@ -173,11 +189,18 @@ pub fn check_pat_variant(pcx: &pat_ctxt, pat: @ast::pat, path: @ast::Path,
             kind_name = "structure";
         }
         _ => {
-            tcx.sess.span_fatal(
-                pat.span,
-                fmt!("mismatched types: expected `%s` but found enum or \
-                      structure",
-                     fcx.infcx().ty_to_str(expected)));
+            let resolved_expected =
+                fcx.infcx().ty_to_str(fcx.infcx().resolve_type_vars_if_possible(expected));
+            fcx.infcx().type_error_message_str(pat.span,
+                                               |actual| {
+                    fmt!("mismatched types: expected `%s` but found %s",
+                         resolved_expected, actual)},
+                    ~"an enum or structure pattern",
+                    None);
+            fcx.write_error(pat.id);
+            kind_name = "[error]";
+            arg_types = (copy subpats).get_or_default(~[]).map(|_|
+                                                               ty::mk_err());
         }
     }
 
@@ -195,8 +218,7 @@ pub fn check_pat_variant(pcx: &pat_ctxt, pat: @ast::pat, path: @ast::Path,
     if arg_len > 0 {
         // N-ary variant.
         if arg_len != subpats_len {
-            let s = fmt!("this pattern has %u field%s, but the corresponding \
-                          %s has %u field%s",
+            let s = fmt!("this pattern has %u field%s, but the corresponding %s has %u field%s",
                          subpats_len,
                          if subpats_len == 1u { ~"" } else { ~"s" },
                          kind_name,
@@ -214,13 +236,12 @@ pub fn check_pat_variant(pcx: &pat_ctxt, pat: @ast::pat, path: @ast::Path,
             }
         }
     } else if subpats_len > 0 {
-        tcx.sess.span_err
-            (pat.span, fmt!("this pattern has %u field%s, but the \
-                             corresponding %s has no fields",
-                            subpats_len,
-                            if subpats_len == 1u { ~"" }
-                            else { ~"s" },
-                            kind_name));
+        tcx.sess.span_err(pat.span,
+                          fmt!("this pattern has %u field%s, but the corresponding %s has no \
+                                fields",
+                               subpats_len,
+                               if subpats_len == 1u { "" } else { "s" },
+                               kind_name));
         error_happened = true;
     }
 
@@ -310,20 +331,19 @@ pub fn check_struct_pat(pcx: &pat_ctxt, pat_id: ast::node_id, span: span,
         Some(&ast::def_struct(*)) | Some(&ast::def_variant(*)) => {
             let name = pprust::path_to_str(path, tcx.sess.intr());
             tcx.sess.span_err(span,
-                              fmt!("mismatched types: expected `%s` but \
-                                    found `%s`",
+                              fmt!("mismatched types: expected `%s` but found `%s`",
                                    fcx.infcx().ty_to_str(expected),
                                    name));
         }
         _ => {
-            tcx.sess.span_bug(span, ~"resolve didn't write in class");
+            tcx.sess.span_bug(span, "resolve didn't write in class");
         }
     }
 
     // Forbid pattern-matching structs with destructors.
     if ty::has_dtor(tcx, class_id) {
-        tcx.sess.span_err(span, ~"deconstructing struct not allowed in \
-                                  pattern (it has a destructor)");
+        tcx.sess.span_err(span, "deconstructing struct not allowed in pattern \
+                                 (it has a destructor)");
     }
 
     check_struct_pat_fields(pcx, span, path, fields, class_fields, class_id,
@@ -361,7 +381,7 @@ pub fn check_struct_like_enum_variant_pat(pcx: &pat_ctxt,
                                    name));
         }
         _ => {
-            tcx.sess.span_bug(span, ~"resolve didn't write in variant");
+            tcx.sess.span_bug(span, "resolve didn't write in variant");
         }
     }
 }
@@ -395,10 +415,9 @@ pub fn check_pat(pcx: &pat_ctxt, pat: @ast::pat, expected: ty::t) {
         {
             // no-op
         } else if !ty::type_is_numeric(b_ty) {
-            tcx.sess.span_err(pat.span, ~"non-numeric type used in range");
+            tcx.sess.span_err(pat.span, "non-numeric type used in range");
         } else if !valid_range_bounds(fcx.ccx, begin, end) {
-            tcx.sess.span_err(begin.span, ~"lower range bound must be less \
-                                           than upper");
+            tcx.sess.span_err(begin.span, "lower range bound must be less than upper");
         }
         fcx.write_ty(pat.id, b_ty);
       }
@@ -467,9 +486,8 @@ pub fn check_pat(pcx: &pat_ctxt, pat: @ast::pat, expected: ty::t) {
             }
             _ => {
                 tcx.sess.span_err(pat.span,
-                                    fmt!("mismatched types: expected `%s` \
-                                          but found struct",
-                                         fcx.infcx().ty_to_str(expected)));
+                                  fmt!("mismatched types: expected `%s` but found struct",
+                                       fcx.infcx().ty_to_str(expected)));
                 error_happened = true;
             }
         }
@@ -484,74 +502,44 @@ pub fn check_pat(pcx: &pat_ctxt, pat: @ast::pat, expected: ty::t) {
       }
       ast::pat_tup(ref elts) => {
         let s = structure_of(fcx, pat.span, expected);
-        let ex_elts = match s {
-          ty::ty_tup(ref elts) => elts,
-          _ => {
-            tcx.sess.span_fatal
-                (pat.span,
-                 fmt!("mismatched types: expected `%s`, found tuple",
-                      fcx.infcx().ty_to_str(expected)));
-          }
-        };
         let e_count = elts.len();
-        if e_count != ex_elts.len() {
-            tcx.sess.span_fatal
-                (pat.span, fmt!("mismatched types: expected a tuple \
-                      with %u fields, found one with %u \
-                      fields", ex_elts.len(), e_count));
-        }
-        let mut i = 0u;
-        for elts.each |elt| {
-            check_pat(pcx, *elt, ex_elts[i]);
-            i += 1u;
+        match s {
+            ty::ty_tup(ref ex_elts) if e_count == ex_elts.len() => {
+                for elts.eachi |i, elt| {
+                    check_pat(pcx, *elt, ex_elts[i]);
+                }
+                fcx.write_ty(pat.id, expected);
+            }
+            _ => {
+                for elts.each |elt| {
+                    check_pat(pcx, *elt, ty::mk_err());
+                }
+                let actual = ty::mk_tup(tcx, elts.map(|pat_var| {
+                    fcx.node_ty(pat_var.id)
+                }));
+                // use terr_tuple_size if both types are tuples
+                let type_error = match s {
+                    ty::ty_tup(ref ex_elts) =>
+                        ty::terr_tuple_size(ty::expected_found{expected: ex_elts.len(),
+                                                           found: e_count}),
+                    _ => ty::terr_mismatch
+                };
+                fcx.infcx().report_mismatched_types(pat.span,
+                                                    expected,
+                                                    actual,
+                                                    &type_error);
+                fcx.write_error(pat.id);
+            }
         }
-
-        fcx.write_ty(pat.id, expected);
       }
       ast::pat_box(inner) => {
-        match structure_of(fcx, pat.span, expected) {
-          ty::ty_box(e_inner) => {
-            check_pat(pcx, inner, e_inner.ty);
-            fcx.write_ty(pat.id, expected);
-          }
-          _ => {
-            tcx.sess.span_fatal(
-                pat.span,
-                ~"mismatched types: expected `" +
-                fcx.infcx().ty_to_str(expected) +
-                ~"` found box");
-          }
-        }
+          check_pointer_pat(pcx, Managed, inner, pat.id, pat.span, expected);
       }
       ast::pat_uniq(inner) => {
-        match structure_of(fcx, pat.span, expected) {
-          ty::ty_uniq(e_inner) => {
-            check_pat(pcx, inner, e_inner.ty);
-            fcx.write_ty(pat.id, expected);
-          }
-          _ => {
-            tcx.sess.span_fatal(
-                pat.span,
-                ~"mismatched types: expected `" +
-                fcx.infcx().ty_to_str(expected) +
-                ~"` found uniq");
-          }
-        }
+          check_pointer_pat(pcx, Owned, inner, pat.id, pat.span, expected);
       }
       ast::pat_region(inner) => {
-        match structure_of(fcx, pat.span, expected) {
-          ty::ty_rptr(_, e_inner) => {
-            check_pat(pcx, inner, e_inner.ty);
-            fcx.write_ty(pat.id, expected);
-          }
-          _ => {
-            tcx.sess.span_fatal(
-                pat.span,
-                ~"mismatched types: expected `" +
-                fcx.infcx().ty_to_str(expected) +
-                ~"` found borrowed pointer");
-          }
-        }
+          check_pointer_pat(pcx, Borrowed, inner, pat.id, pat.span, expected);
       }
       ast::pat_vec(ref before, slice, ref after) => {
         let default_region_var =
@@ -575,11 +563,25 @@ pub fn check_pat(pcx: &pat_ctxt, pat: @ast::pat, expected: ty::t) {
             (mt, default_region_var)
           },
           _ => {
-            tcx.sess.span_fatal(
-                pat.span,
-                fmt!("mismatched type: expected `%s` but found vector",
-                     fcx.infcx().ty_to_str(expected))
-            );
+              for before.each |&elt| {
+                  check_pat(pcx, elt, ty::mk_err());
+              }
+              for slice.each |&elt| {
+                  check_pat(pcx, elt, ty::mk_err());
+              }
+              for after.each |&elt| {
+                  check_pat(pcx, elt, ty::mk_err());
+              }
+              let resolved_expected =
+                  fcx.infcx().ty_to_str(fcx.infcx().resolve_type_vars_if_possible(expected));
+              fcx.infcx().type_error_message_str(pat.span,
+                  |actual| {
+                      fmt!("mismatched types: expected `%s` but found %s",
+                           resolved_expected, actual)},
+                                                 ~"a vector pattern",
+                                                 None);
+              fcx.write_error(pat.id);
+              return;
           }
         };
         for before.each |elt| {
@@ -603,3 +605,45 @@ pub fn check_pat(pcx: &pat_ctxt, pat: @ast::pat, expected: ty::t) {
     }
 }
 
+// Helper function to check @, ~ and & patterns
+pub fn check_pointer_pat(pcx: &pat_ctxt,
+                         pointer_kind: PointerKind,
+                         inner: @ast::pat,
+                         pat_id: ast::node_id,
+                         span: span,
+                         expected: ty::t) {
+    let fcx = pcx.fcx;
+    let check_inner: &fn(ty::mt) = |e_inner| {
+        check_pat(pcx, inner, e_inner.ty);
+        fcx.write_ty(pat_id, expected);
+    };
+    match structure_of(fcx, span, expected) {
+        ty::ty_box(e_inner) if pointer_kind == Managed => {
+            check_inner(e_inner);
+        }
+        ty::ty_uniq(e_inner) if pointer_kind == Owned => {
+            check_inner(e_inner);
+        }
+        ty::ty_rptr(_, e_inner) if pointer_kind == Borrowed => {
+            check_inner(e_inner);
+        }
+        _ => {
+            check_pat(pcx, inner, ty::mk_err());
+            let resolved_expected =
+                fcx.infcx().ty_to_str(fcx.infcx().resolve_type_vars_if_possible(expected));
+            fcx.infcx().type_error_message_str(span, |actual| {
+                    fmt!("mismatched types: expected `%s` but found %s",
+                         resolved_expected, actual)},
+                                               fmt!("%s pattern", match pointer_kind {
+                                                   Managed => "an @-box",
+                                                   Owned => "a ~-box",
+                                                   Borrowed => "an &-pointer"
+                                               }),
+                    None);
+            fcx.write_error(pat_id);
+          }
+    }
+}
+
+#[deriving(Eq)]
+enum PointerKind { Managed, Owned, Borrowed }
diff --git a/src/librustc/middle/typeck/check/demand.rs b/src/librustc/middle/typeck/check/demand.rs
index 1bb71c156c3..3fa551e4b05 100644
--- a/src/librustc/middle/typeck/check/demand.rs
+++ b/src/librustc/middle/typeck/check/demand.rs
@@ -66,5 +66,3 @@ pub fn coerce(fcx: @mut FnCtxt,
       }
     }
 }
-
-
diff --git a/src/librustc/middle/typeck/check/method.rs b/src/librustc/middle/typeck/check/method.rs
index 9f9132fa946..08398f9880a 100644
--- a/src/librustc/middle/typeck/check/method.rs
+++ b/src/librustc/middle/typeck/check/method.rs
@@ -876,7 +876,7 @@ pub impl<'self> LookupContext<'self> {
         if relevant_candidates.len() > 1 {
             self.tcx().sess.span_err(
                 self.expr.span,
-                ~"multiple applicable methods in scope");
+                "multiple applicable methods in scope");
             for uint::range(0, relevant_candidates.len()) |idx| {
                 self.report_candidate(idx, &relevant_candidates[idx].origin);
             }
@@ -987,12 +987,12 @@ pub impl<'self> LookupContext<'self> {
             } else if num_method_tps == 0u {
                 tcx.sess.span_err(
                     self.expr.span,
-                    ~"this method does not take type parameters");
+                    "this method does not take type parameters");
                 self.fcx.infcx().next_ty_vars(num_method_tps)
             } else if num_supplied_tps != num_method_tps {
                 tcx.sess.span_err(
                     self.expr.span,
-                    ~"incorrect number of type \
+                    "incorrect number of type \
                      parameters given for this method");
                 self.fcx.infcx().next_ty_vars(num_method_tps)
             } else {
@@ -1085,14 +1085,14 @@ pub impl<'self> LookupContext<'self> {
         if ty::type_has_self(method_fty) {
             self.tcx().sess.span_err(
                 self.expr.span,
-                ~"cannot call a method whose type contains a \
-                  self-type through a boxed trait");
+                "cannot call a method whose type contains a \
+                 self-type through a boxed trait");
         }
 
         if candidate.method_ty.generics.has_type_params() {
             self.tcx().sess.span_err(
                 self.expr.span,
-                ~"cannot call a generic method through a boxed trait");
+                "cannot call a generic method through a boxed trait");
         }
     }
 
@@ -1112,7 +1112,7 @@ pub impl<'self> LookupContext<'self> {
 
         if bad {
             self.tcx().sess.span_err(self.expr.span,
-                                     ~"explicit call to destructor");
+                                     "explicit call to destructor");
         }
     }
 
diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs
index 09022b5829a..5357d092a90 100644
--- a/src/librustc/middle/typeck/check/mod.rs
+++ b/src/librustc/middle/typeck/check/mod.rs
@@ -542,45 +542,20 @@ pub fn check_no_duplicate_fields(tcx: ty::ctxt,
         let (id, sp) = *p;
         let orig_sp = field_names.find(&id).map_consume(|x| *x);
         match orig_sp {
-          Some(orig_sp) => {
-            tcx.sess.span_err(sp, fmt!("Duplicate field \
-                                   name %s in record type declaration",
-                                        *tcx.sess.str_of(id)));
-            tcx.sess.span_note(orig_sp, ~"First declaration of \
-                                          this field occurred here");
-            break;
-          }
-          None => {
-            field_names.insert(id, sp);
-          }
+            Some(orig_sp) => {
+                tcx.sess.span_err(sp, fmt!("Duplicate field name %s in record type declaration",
+                                           *tcx.sess.str_of(id)));
+                tcx.sess.span_note(orig_sp, "First declaration of this field occurred here");
+                break;
+            }
+            None => {
+                field_names.insert(id, sp);
+            }
         }
     }
 }
 
-pub fn check_struct(ccx: @mut CrateCtxt,
-                    struct_def: @ast::struct_def,
-                    id: ast::node_id,
-                    span: span) {
-    let tcx = ccx.tcx;
-    let self_ty = ty::node_id_to_type(tcx, id);
-
-    for struct_def.dtor.each |dtor| {
-        let class_t = SelfInfo {
-            self_ty: self_ty,
-            self_id: dtor.node.self_id,
-            span: dtor.span,
-        };
-        // typecheck the dtor
-        let dtor_dec = ast_util::dtor_dec();
-        check_bare_fn(
-            ccx,
-            &dtor_dec,
-            &dtor.node.body,
-            dtor.node.id,
-            Some(class_t)
-        );
-    };
-
+pub fn check_struct(ccx: @mut CrateCtxt, id: ast::node_id, span: span) {
     // Check that the class is instantiable
     check_instantiable(ccx.tcx, span, id);
 }
@@ -623,8 +598,8 @@ pub fn check_item(ccx: @mut CrateCtxt, it: @ast::item) {
             }
         }
       }
-      ast::item_struct(struct_def, _) => {
-        check_struct(ccx, struct_def, it.id, it.span);
+      ast::item_struct(*) => {
+        check_struct(ccx, it.id, it.span);
       }
       ast::item_ty(t, ref generics) => {
         let tpt_ty = ty::node_id_to_type(ccx.tcx, it.id);
@@ -1272,8 +1247,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
                                 ty::ty_rptr(_, mt) => formal_ty = mt.ty,
                                 ty::ty_err => (),
                                 _ => {
-                                    fcx.ccx.tcx.sess.span_bug(arg.span,
-                                                              ~"no ref");
+                                    fcx.ccx.tcx.sess.span_bug(arg.span, "no ref");
                                 }
                             }
                         }
@@ -1588,8 +1562,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
             match ty::get(lhs_resolved_t).sty {
                 ty::ty_bare_fn(_) | ty::ty_closure(_) => {
                     tcx.sess.span_note(
-                        ex.span, ~"did you forget the `do` keyword \
-                                   for the call?");
+                        ex.span, "did you forget the `do` keyword for the call?");
                 }
                 _ => ()
             }
@@ -1880,9 +1853,9 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
                 tcx.sess.span_err(span,
                                   fmt!("missing field%s: %s",
                                        if missing_fields.len() == 1 {
-                                           ~""
+                                           ""
                                        } else {
-                                           ~"s"
+                                           "s"
                                        },
                                        str::connect(missing_fields, ~", ")));
              }
@@ -1930,7 +1903,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
                 }
                 _ => {
                     tcx.sess.span_bug(span,
-                                      ~"resolve didn't map this to a class");
+                                      "resolve didn't map this to a class");
                 }
             }
         } else {
@@ -2016,7 +1989,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
                 }
                 _ => {
                     tcx.sess.span_bug(span,
-                                      ~"resolve didn't map this to an enum");
+                                      "resolve didn't map this to an enum");
                 }
             }
         } else {
@@ -2226,7 +2199,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
             }
           }
           _ =>
-            tcx.sess.span_bug(expr.span, ~"vstore modifier on non-sequence")
+            tcx.sess.span_bug(expr.span, "vstore modifier on non-sequence")
         };
         fcx.write_ty(ev.id, typ);
         fcx.write_ty(id, typ);
@@ -2309,21 +2282,18 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
                                 ty::ty_enum(*) => {
                                     tcx.sess.span_err(
                                         expr.span,
-                                        ~"can only dereference enums \
-                                          with a single variant which has a \
-                                          single argument");
+                                        "can only dereference enums with a single variant which \
+                                         has a single argument");
                                 }
                                 ty::ty_struct(*) => {
                                     tcx.sess.span_err(
                                         expr.span,
-                                        ~"can only dereference structs with \
-                                          one anonymous field");
+                                        "can only dereference structs with one anonymous field");
                                 }
                                 _ => {
                                     fcx.type_error_message(expr.span,
                                         |actual| {
-                                            fmt!("type %s cannot be \
-                                                  dereferenced", actual)
+                                            fmt!("type %s cannot be dereferenced", actual)
                                     }, oprnd_t, None);
                                 }
                             }
@@ -2417,7 +2387,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
             result::Err(_) => {
                 tcx.sess.span_err(
                     expr.span,
-                    ~"`return;` in function returning non-nil");
+                    "`return;` in function returning non-nil");
             }
           },
           Some(e) => {
@@ -2781,8 +2751,8 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
                                           variant_id, *fields);
             }
             _ => {
-                tcx.sess.span_bug(path.span, ~"structure constructor does \
-                                               not name a structure type");
+                tcx.sess.span_bug(path.span,
+                                  "structure constructor does not name a structure type");
             }
         }
       }
@@ -2985,7 +2955,7 @@ pub fn check_block_with_expected(fcx: @mut FnCtxt,
                   }
                   _ => false
                 } {
-                fcx.ccx.tcx.sess.span_warn(s.span, ~"unreachable statement");
+                fcx.ccx.tcx.sess.span_warn(s.span, "unreachable statement");
                 warned = true;
             }
             if ty::type_is_bot(s_ty) {
@@ -3006,7 +2976,7 @@ pub fn check_block_with_expected(fcx: @mut FnCtxt,
             },
           Some(e) => {
             if any_bot && !warned {
-                fcx.ccx.tcx.sess.span_warn(e.span, ~"unreachable expression");
+                fcx.ccx.tcx.sess.span_warn(e.span, "unreachable expression");
             }
             check_expr_with_opt_hint(fcx, e, expected);
               let ety = fcx.expr_ty(e);
@@ -3097,8 +3067,8 @@ pub fn check_enum_variants(ccx: @mut CrateCtxt,
                     *disr_val = val as int;
                   }
                   Ok(_) => {
-                    ccx.tcx.sess.span_err(e.span, ~"expected signed integer \
-                                                    constant");
+                    ccx.tcx.sess.span_err(e.span, "expected signed integer \
+                                                   constant");
                   }
                   Err(ref err) => {
                     ccx.tcx.sess.span_err(e.span,
@@ -3109,7 +3079,7 @@ pub fn check_enum_variants(ccx: @mut CrateCtxt,
             }
             if vec::contains(*disr_vals, &*disr_val) {
                 ccx.tcx.sess.span_err(v.span,
-                                      ~"discriminator value already exists");
+                                      "discriminator value already exists");
             }
             disr_vals.push(*disr_val);
             let ctor_ty = ty::node_id_to_type(ccx.tcx, v.node.id);
@@ -3166,9 +3136,9 @@ pub fn check_enum_variants(ccx: @mut CrateCtxt,
           _ => false
         }
     }) {
-        ccx.tcx.sess.span_err(sp, ~"illegal recursive enum type; \
-                                 wrap the inner value in a box to \
-                                 make it representable");
+        ccx.tcx.sess.span_err(sp,
+                              "illegal recursive enum type; \
+                               wrap the inner value in a box to make it representable");
     }
 
     // Check that it is possible to instantiate this enum:
@@ -3229,26 +3199,25 @@ pub fn ty_param_bounds_and_ty_for_def(fcx: @mut FnCtxt,
       ast::def_ty(_) |
       ast::def_prim_ty(_) |
       ast::def_ty_param(*)=> {
-        fcx.ccx.tcx.sess.span_bug(sp, ~"expected value but found type");
+        fcx.ccx.tcx.sess.span_bug(sp, "expected value but found type");
       }
       ast::def_mod(*) | ast::def_foreign_mod(*) => {
-        fcx.ccx.tcx.sess.span_bug(sp, ~"expected value but found module");
+        fcx.ccx.tcx.sess.span_bug(sp, "expected value but found module");
       }
       ast::def_use(*) => {
-        fcx.ccx.tcx.sess.span_bug(sp, ~"expected value but found use");
+        fcx.ccx.tcx.sess.span_bug(sp, "expected value but found use");
       }
       ast::def_region(*) => {
-        fcx.ccx.tcx.sess.span_bug(sp, ~"expected value but found region");
+        fcx.ccx.tcx.sess.span_bug(sp, "expected value but found region");
       }
       ast::def_typaram_binder(*) => {
-        fcx.ccx.tcx.sess.span_bug(sp, ~"expected value but found type \
-                                          parameter");
+        fcx.ccx.tcx.sess.span_bug(sp, "expected value but found type parameter");
       }
       ast::def_label(*) => {
-        fcx.ccx.tcx.sess.span_bug(sp, ~"expected value but found label");
+        fcx.ccx.tcx.sess.span_bug(sp, "expected value but found label");
       }
       ast::def_self_ty(*) => {
-        fcx.ccx.tcx.sess.span_bug(sp, ~"expected value but found self ty");
+        fcx.ccx.tcx.sess.span_bug(sp, "expected value but found self ty");
       }
     }
 }
@@ -3276,7 +3245,7 @@ pub fn instantiate_path(fcx: @mut FnCtxt,
         match tpt.generics.region_param {
           None => { // ...but the type is not lifetime parameterized!
             fcx.ccx.tcx.sess.span_err
-                (span, ~"this item is not region-parameterized");
+                (span, "this item is not region-parameterized");
             None
           }
           Some(_) => { // ...and the type is lifetime parameterized, ok.
@@ -3295,15 +3264,15 @@ pub fn instantiate_path(fcx: @mut FnCtxt,
         fcx.infcx().next_ty_vars(ty_param_count)
     } else if ty_param_count == 0 {
         fcx.ccx.tcx.sess.span_err
-            (span, ~"this item does not take type parameters");
+            (span, "this item does not take type parameters");
         fcx.infcx().next_ty_vars(ty_param_count)
     } else if ty_substs_len > ty_param_count {
         fcx.ccx.tcx.sess.span_err
-            (span, ~"too many type parameters provided for this item");
+            (span, "too many type parameters provided for this item");
         fcx.infcx().next_ty_vars(ty_param_count)
     } else if ty_substs_len < ty_param_count {
         fcx.ccx.tcx.sess.span_err
-            (span, ~"not enough type parameters provided for this item");
+            (span, "not enough type parameters provided for this item");
         fcx.infcx().next_ty_vars(ty_param_count)
     } else {
         pth.types.map(|aty| fcx.to_ty(*aty))
diff --git a/src/librustc/middle/typeck/check/regionck.rs b/src/librustc/middle/typeck/check/regionck.rs
index 1b0a22752a5..36606ab7d89 100644
--- a/src/librustc/middle/typeck/check/regionck.rs
+++ b/src/librustc/middle/typeck/check/regionck.rs
@@ -613,17 +613,17 @@ fn constrain_free_variables(rcx: @mut Rcx,
           result::Err(_) => {
             tcx.sess.span_err(
                 freevar.span,
-                ~"captured variable does not outlive the enclosing closure");
+                "captured variable does not outlive the enclosing closure");
             note_and_explain_region(
                 tcx,
-                ~"captured variable is valid for ",
+                "captured variable is valid for ",
                 en_region,
-                ~"");
+                "");
             note_and_explain_region(
                 tcx,
-                ~"closure is valid for ",
+                "closure is valid for ",
                 region,
-                ~"");
+                "");
           }
         }
     }
diff --git a/src/librustc/middle/typeck/check/vtable.rs b/src/librustc/middle/typeck/check/vtable.rs
index 100e23e024c..b5bd5a48e9d 100644
--- a/src/librustc/middle/typeck/check/vtable.rs
+++ b/src/librustc/middle/typeck/check/vtable.rs
@@ -417,7 +417,7 @@ fn lookup_vtable(vcx: &VtableContext,
                     if !is_early {
                         vcx.tcx().sess.span_err(
                             location_info.span,
-                            ~"multiple applicable methods in scope");
+                            "multiple applicable methods in scope");
                     }
                     return Some(/*bad*/copy found[0]);
                 }
@@ -669,5 +669,3 @@ pub fn resolve_in_block(fcx: @mut FnCtxt, bl: &ast::blk) {
         .. *visit::default_visitor()
     }));
 }
-
-
diff --git a/src/librustc/middle/typeck/coherence.rs b/src/librustc/middle/typeck/coherence.rs
index 09f0b83e616..82ef09a83be 100644
--- a/src/librustc/middle/typeck/coherence.rs
+++ b/src/librustc/middle/typeck/coherence.rs
@@ -76,10 +76,8 @@ pub fn get_base_type(inference_context: @mut InferCtxt,
         }
         _ => {
             inference_context.tcx.sess.span_fatal(span,
-                                                  ~"the type of this value \
-                                                    must be known in order \
-                                                    to determine the base \
-                                                    type");
+                                                  "the type of this value must be known in order \
+                                                   to determine the base type");
         }
     }
 
@@ -257,9 +255,8 @@ pub impl CoherenceChecker {
                 None => {
                     let session = self.crate_context.tcx.sess;
                     session.span_err(item.span,
-                                     ~"no base type found for inherent \
-                                       implementation; implement a \
-                                       trait or new type instead");
+                                     "no base type found for inherent implementation; \
+                                      implement a trait or new type instead");
                 }
                 Some(_) => {
                     // Nothing to do.
@@ -481,11 +478,9 @@ pub impl CoherenceChecker {
                     if self.polytypes_unify(polytype_a, polytype_b) {
                         let session = self.crate_context.tcx.sess;
                         session.span_err(self.span_of_impl(implementation_b),
-                                         ~"conflicting implementations for a \
-                                           trait");
+                                         "conflicting implementations for a trait");
                         session.span_note(self.span_of_impl(implementation_a),
-                                          ~"note conflicting implementation \
-                                            here");
+                                          "note conflicting implementation here");
                     }
                 }
             }
@@ -668,11 +663,9 @@ pub impl CoherenceChecker {
                             // This is an error.
                             let session = self.crate_context.tcx.sess;
                             session.span_err(item.span,
-                                             ~"cannot associate methods with \
-                                               a type outside the crate the \
-                                               type is defined in; define \
-                                               and implement a trait or new \
-                                               type instead");
+                                             "cannot associate methods with a type outside the \
+                                              crate the type is defined in; define and implement \
+                                              a trait or new type instead");
                         }
                     }
                     item_impl(_, Some(trait_ref), _, _) => {
@@ -691,10 +684,8 @@ pub impl CoherenceChecker {
                             if trait_def_id.crate != local_crate {
                                 let session = self.crate_context.tcx.sess;
                                 session.span_err(item.span,
-                                                 ~"cannot provide an \
-                                                   extension implementation \
-                                                   for a trait not defined \
-                                                   in this crate");
+                                                 "cannot provide an extension implementation \
+                                                  for a trait not defined in this crate");
                             }
                         }
 
@@ -766,7 +757,7 @@ pub impl CoherenceChecker {
                             None => {
                                 self.crate_context.tcx.sess.span_bug(
                                     original_type.span,
-                                    ~"resolve didn't resolve this type?!");
+                                    "resolve didn't resolve this type?!");
                             }
                             Some(&node_item(item, _)) => {
                                 match item.node {
@@ -850,8 +841,7 @@ pub impl CoherenceChecker {
             }
             _ => {
                 self.crate_context.tcx.sess.span_bug(item.span,
-                                                     ~"can't convert a \
-                                                       non-impl to an impl");
+                                                     "can't convert a non-impl to an impl");
             }
         }
     }
@@ -863,9 +853,8 @@ pub impl CoherenceChecker {
                 return item.span;
             }
             _ => {
-                self.crate_context.tcx.sess.bug(~"span_of_impl() called on \
-                                                  something that wasn't an \
-                                                  impl!");
+                self.crate_context.tcx.sess.bug("span_of_impl() called on something that \
+                                                 wasn't an impl!");
             }
         }
     }
@@ -1046,17 +1035,16 @@ pub impl CoherenceChecker {
                         match tcx.items.find(&impl_info.did.node) {
                             Some(&ast_map::node_item(@ref item, _)) => {
                                 tcx.sess.span_err((*item).span,
-                                                  ~"the Drop trait may only \
-                                                    be implemented on \
-                                                    structures");
+                                                  "the Drop trait may only be implemented on \
+                                                   structures");
                             }
                             _ => {
-                                tcx.sess.bug(~"didn't find impl in ast map");
+                                tcx.sess.bug("didn't find impl in ast map");
                             }
                         }
                     } else {
-                        tcx.sess.bug(~"found external impl of Drop trait on \
-                                       something other than a struct");
+                        tcx.sess.bug("found external impl of Drop trait on \
+                                      something other than a struct");
                     }
                 }
             }
@@ -1132,4 +1120,3 @@ pub fn check_coherence(crate_context: @mut CrateCtxt, crate: @crate) {
     let coherence_checker = @CoherenceChecker(crate_context);
     coherence_checker.check_coherence(crate);
 }
-
diff --git a/src/librustc/middle/typeck/collect.rs b/src/librustc/middle/typeck/collect.rs
index 3da6995b423..22850c16f94 100644
--- a/src/librustc/middle/typeck/collect.rs
+++ b/src/librustc/middle/typeck/collect.rs
@@ -49,7 +49,6 @@ use syntax::ast::{RegionTyParamBound, TraitTyParamBound};
 use syntax::ast;
 use syntax::ast_map;
 use syntax::ast_util::{local_def, split_trait_methods};
-use syntax::ast_util;
 use syntax::codemap::span;
 use syntax::codemap;
 use syntax::print::pprust::{path_to_str, self_ty_to_str};
@@ -152,7 +151,7 @@ impl AstConv for CrateCtxt {
 
     fn ty_infer(&self, span: span) -> ty::t {
         self.tcx.sess.span_bug(span,
-                               ~"found `ty_infer` in unexpected place");
+                               "found `ty_infer` in unexpected place");
     }
 }
 
@@ -417,8 +416,7 @@ pub fn ensure_supertraits(ccx: &CrateCtxt,
         if ty_trait_refs.any(|other_trait| other_trait.def_id == trait_ref.def_id) {
             // This means a trait inherited from the same supertrait more
             // than once.
-            tcx.sess.span_err(sp, ~"Duplicate supertrait in trait \
-                                     declaration");
+            tcx.sess.span_err(sp, "Duplicate supertrait in trait declaration");
             break;
         } else {
             ty_trait_refs.push(trait_ref);
@@ -897,30 +895,6 @@ pub fn convert_struct(ccx: &CrateCtxt,
                       id: ast::node_id) {
     let tcx = ccx.tcx;
 
-    for struct_def.dtor.each |dtor| {
-        let region_parameterization =
-            RegionParameterization::from_variance_and_generics(rp, generics);
-
-        // Write the dtor type
-        let t_dtor = ty::mk_bare_fn(
-            tcx,
-            astconv::ty_of_bare_fn(
-                ccx,
-                &type_rscope(region_parameterization),
-                ast::impure_fn,
-                AbiSet::Rust(),
-                &opt_vec::Empty,
-                &ast_util::dtor_dec()));
-        write_ty_to_tcx(tcx, dtor.node.id, t_dtor);
-        tcx.tcache.insert(local_def(dtor.node.id),
-                          ty_param_bounds_and_ty {
-                              generics: ty::Generics {
-                                  type_param_defs: tpt.generics.type_param_defs,
-                                  region_param: rp
-                              },
-                              ty: t_dtor});
-    };
-
     // Write the type of each of the members
     for struct_def.fields.each |f| {
        convert_field(ccx, rp, tpt.generics.type_param_defs, *f, generics);
diff --git a/src/librustc/middle/typeck/infer/combine.rs b/src/librustc/middle/typeck/infer/combine.rs
index e4db423c2e3..362104e98b0 100644
--- a/src/librustc/middle/typeck/infer/combine.rs
+++ b/src/librustc/middle/typeck/infer/combine.rs
@@ -480,6 +480,8 @@ pub fn super_tys<C:Combine>(
             unify_float_variable(self, !self.a_is_expected(), v_id, v)
         }
 
+      (ty::ty_nil, _) |
+      (ty::ty_bool, _) |
       (ty::ty_int(_), _) |
       (ty::ty_uint(_), _) |
       (ty::ty_float(_), _) => {
@@ -490,16 +492,6 @@ pub fn super_tys<C:Combine>(
         }
       }
 
-      (ty::ty_nil, _) |
-      (ty::ty_bool, _) => {
-        let cfg = tcx.sess.targ_cfg;
-        if ty::mach_sty(cfg, a) == ty::mach_sty(cfg, b) {
-            Ok(a)
-        } else {
-            Err(ty::terr_sorts(expected_found(self, a, b)))
-        }
-      }
-
       (ty::ty_param(ref a_p), ty::ty_param(ref b_p)) if a_p.idx == b_p.idx => {
         Ok(a)
       }
@@ -643,4 +635,3 @@ pub fn super_trait_refs<C:Combine>(
         })
     }
 }
-
diff --git a/src/librustc/middle/typeck/infer/glb.rs b/src/librustc/middle/typeck/infer/glb.rs
index b818f666444..c195454b532 100644
--- a/src/librustc/middle/typeck/infer/glb.rs
+++ b/src/librustc/middle/typeck/infer/glb.rs
@@ -315,4 +315,3 @@ impl Combine for Glb {
         super_trait_refs(self, a, b)
     }
 }
-
diff --git a/src/librustc/middle/typeck/infer/macros.rs b/src/librustc/middle/typeck/infer/macros.rs
index e02772d951c..306f124be3c 100644
--- a/src/librustc/middle/typeck/infer/macros.rs
+++ b/src/librustc/middle/typeck/infer/macros.rs
@@ -18,4 +18,3 @@ macro_rules! if_ok(
         }
     )
 )
-
diff --git a/src/librustc/middle/typeck/infer/mod.rs b/src/librustc/middle/typeck/infer/mod.rs
index 899b8cfd7ed..2e784b11c35 100644
--- a/src/librustc/middle/typeck/infer/mod.rs
+++ b/src/librustc/middle/typeck/infer/mod.rs
@@ -728,25 +728,32 @@ pub impl InferCtxt {
         }
     }
 
-    fn type_error_message(@mut self, sp: span, mk_msg: &fn(~str) -> ~str,
-                          actual_ty: ty::t, err: Option<&ty::type_err>) {
-        let actual_ty = self.resolve_type_vars_if_possible(actual_ty);
 
-        // Don't report an error if actual type is ty_err.
-        if ty::type_is_error(actual_ty) {
-            return;
-        }
+    fn type_error_message_str(@mut self, sp: span, mk_msg: &fn(~str) -> ~str,
+                          actual_ty: ~str, err: Option<&ty::type_err>) {
         let error_str = err.map_default(~"", |t_err|
                          fmt!(" (%s)",
                               ty::type_err_to_str(self.tcx, *t_err)));
         self.tcx.sess.span_err(sp,
-           fmt!("%s%s", mk_msg(self.ty_to_str(actual_ty)),
-                error_str));
+           fmt!("%s%s", mk_msg(actual_ty), error_str));
         for err.each |err| {
             ty::note_and_explain_type_err(self.tcx, *err)
         }
     }
 
+    fn type_error_message(@mut self, sp: span, mk_msg: &fn(~str) -> ~str,
+                          actual_ty: ty::t, err: Option<&ty::type_err>) {
+        let actual_ty = self.resolve_type_vars_if_possible(actual_ty);
+
+        // Don't report an error if actual type is ty_err.
+        if ty::type_is_error(actual_ty) {
+            return;
+        }
+
+        self.type_error_message_str(sp, mk_msg, self.ty_to_str(actual_ty),
+                                    err);
+    }
+
     fn report_mismatched_types(@mut self, sp: span, e: ty::t, a: ty::t,
                                err: &ty::type_err) {
         let resolved_expected =
@@ -793,4 +800,4 @@ pub fn fold_regions_in_sig(
     do ty::fold_sig(fn_sig) |t| {
         ty::fold_regions(tcx, t, fldr)
     }
-}
\ No newline at end of file
+}
diff --git a/src/librustc/middle/typeck/infer/region_inference.rs b/src/librustc/middle/typeck/infer/region_inference.rs
index 0761ad5c7b8..a3b5369d22a 100644
--- a/src/librustc/middle/typeck/infer/region_inference.rs
+++ b/src/librustc/middle/typeck/infer/region_inference.rs
@@ -1584,9 +1584,9 @@ pub impl RegionVarBindings {
 
                     note_and_explain_region(
                         self.tcx,
-                        ~"first, the lifetime cannot outlive ",
+                        "first, the lifetime cannot outlive ",
                         upper_bound.region,
-                        ~"...");
+                        "...");
 
                     self.tcx.sess.span_note(
                         upper_bound.span,
@@ -1594,9 +1594,9 @@ pub impl RegionVarBindings {
 
                     note_and_explain_region(
                         self.tcx,
-                        ~"but, the lifetime must be valid for ",
+                        "but, the lifetime must be valid for ",
                         lower_bound.region,
-                        ~"...");
+                        "...");
 
                     self.tcx.sess.span_note(
                         lower_bound.span,
@@ -1793,4 +1793,3 @@ fn iterate_until_fixed_point(
     }
     debug!("---- %s Complete after %u iteration(s)", tag, iteration);
 }
-
diff --git a/src/librustc/middle/typeck/infer/resolve.rs b/src/librustc/middle/typeck/infer/resolve.rs
index 9b648f6a053..2b88825c49a 100644
--- a/src/librustc/middle/typeck/infer/resolve.rs
+++ b/src/librustc/middle/typeck/infer/resolve.rs
@@ -278,4 +278,3 @@ pub impl ResolveState {
         }
     }
 }
-
diff --git a/src/librustc/middle/typeck/infer/sub.rs b/src/librustc/middle/typeck/infer/sub.rs
index 266d157c4d0..48d7765f88e 100644
--- a/src/librustc/middle/typeck/infer/sub.rs
+++ b/src/librustc/middle/typeck/infer/sub.rs
@@ -269,4 +269,3 @@ impl Combine for Sub {
         super_trait_refs(self, a, b)
     }
 }
-
diff --git a/src/librustc/middle/typeck/infer/unify.rs b/src/librustc/middle/typeck/infer/unify.rs
index 8db4774322a..3bcff923465 100644
--- a/src/librustc/middle/typeck/infer/unify.rs
+++ b/src/librustc/middle/typeck/infer/unify.rs
@@ -264,5 +264,3 @@ impl SimplyUnifiable for ast::float_ty {
         return ty::terr_float_mismatch(err);
     }
 }
-
-
diff --git a/src/librustc/middle/typeck/mod.rs b/src/librustc/middle/typeck/mod.rs
index 646b6412f55..0012eb70030 100644
--- a/src/librustc/middle/typeck/mod.rs
+++ b/src/librustc/middle/typeck/mod.rs
@@ -214,7 +214,7 @@ pub fn lookup_def_tcx(tcx: ty::ctxt, sp: span, id: ast::node_id) -> ast::def {
     match tcx.def_map.find(&id) {
       Some(&x) => x,
       _ => {
-        tcx.sess.span_fatal(sp, ~"internal error looking up a definition")
+        tcx.sess.span_fatal(sp, "internal error looking up a definition")
       }
     }
 }
@@ -301,8 +301,7 @@ fn check_main_fn_ty(ccx: @mut CrateCtxt,
                         if ps.is_parameterized() => {
                             tcx.sess.span_err(
                                 main_span,
-                                ~"main function is not allowed \
-                                  to have type parameters");
+                                "main function is not allowed to have type parameters");
                             return;
                         }
                         _ => ()
@@ -343,8 +342,7 @@ fn check_start_fn_ty(ccx: @mut CrateCtxt,
                         if ps.is_parameterized() => {
                             tcx.sess.span_err(
                                 start_span,
-                                ~"start function is not allowed to have type \
-                                parameters");
+                                "start function is not allowed to have type parameters");
                             return;
                         }
                         _ => ()
@@ -426,12 +424,3 @@ pub fn check_crate(tcx: ty::ctxt,
     tcx.sess.abort_if_errors();
     (ccx.method_map, ccx.vtable_map)
 }
-//
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
-//
diff --git a/src/librustc/rustc.rc b/src/librustc/rustc.rc
index 7191a98e5db..f8a19eaf374 100644
--- a/src/librustc/rustc.rc
+++ b/src/librustc/rustc.rc
@@ -20,7 +20,6 @@
 #[allow(non_implicitly_copyable_typarams)];
 #[allow(non_camel_case_types)];
 #[deny(deprecated_pattern)];
-#[deny(deprecated_mode)];
 
 extern mod std(vers = "0.7-pre");
 extern mod syntax(vers = "0.7-pre");
@@ -362,11 +361,3 @@ pub fn main() {
         run_compiler(&args, demitter);
     }
 }
-
-
-// Local Variables:
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs
index 38f55b2b6e4..b4a479fc597 100644
--- a/src/librustc/util/common.rs
+++ b/src/librustc/util/common.rs
@@ -112,13 +112,3 @@ pub fn pluralize(n: uint, s: ~str) -> ~str {
 
 // A set of node IDs (used to keep track of which node IDs are for statements)
 pub type stmt_set = @mut HashSet<ast::node_id>;
-
-//
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
-//
diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs
index 751fe19f2a2..59a0a1ba3d6 100644
--- a/src/librustc/util/ppaux.rs
+++ b/src/librustc/util/ppaux.rs
@@ -755,11 +755,3 @@ impl Repr for ast_map::path_elt {
         }
     }
 }
-
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End
diff --git a/src/librustdoc/path_pass.rs b/src/librustdoc/path_pass.rs
index 629c6955566..5560f21af61 100644
--- a/src/librustdoc/path_pass.rs
+++ b/src/librustdoc/path_pass.rs
@@ -112,4 +112,3 @@ fn should_record_fn_paths() {
         assert!(doc.cratemod().mods()[0].fns()[0].path() == ~[~"a"]);
     }
 }
-
diff --git a/src/librustdoc/tystr_pass.rs b/src/librustdoc/tystr_pass.rs
index 303bdc53b69..def32bdfd44 100644
--- a/src/librustdoc/tystr_pass.rs
+++ b/src/librustdoc/tystr_pass.rs
@@ -332,13 +332,7 @@ fn fold_struct(
 /// what I actually want
 fn strip_struct_extra_stuff(item: @ast::item) -> @ast::item {
     let node = match copy item.node {
-        ast::item_struct(def, tys) => {
-            let def = @ast::struct_def {
-                dtor: None, // Remove the drop { } block
-                .. copy *def
-            };
-            ast::item_struct(def, tys)
-        }
+        ast::item_struct(def, tys) => ast::item_struct(def, tys),
         _ => fail!(~"not a struct")
     };
 
@@ -441,13 +435,6 @@ mod test {
     }
 
     #[test]
-    fn should_not_serialize_struct_drop_blocks() {
-        // All we care about are the fields
-        let doc = mk_doc(~"struct S { field: (), drop { } }");
-        assert!(!(&doc.cratemod().structs()[0].sig).get().contains("drop"));
-    }
-
-    #[test]
     fn should_not_serialize_struct_attrs() {
         // All we care about are the fields
         let doc = mk_doc(~"#[wut] struct S { field: () }");
diff --git a/src/librustpkg/conditions.rs b/src/librustpkg/conditions.rs
index 35e70af7914..5b19a3bd660 100644
--- a/src/librustpkg/conditions.rs
+++ b/src/librustpkg/conditions.rs
@@ -18,5 +18,13 @@ condition! {
 }
 
 condition! {
-    nonexistent_package: (super::PkgId, ~str) -> super::Path;
+    nonexistent_package: (super::PkgId, ~str) -> ();
+}
+
+condition! {
+    copy_failed: (super::Path, super::Path) -> ();
+}
+
+condition! {
+    missing_pkg_files: (super::PkgId) -> ();
 }
diff --git a/src/librustpkg/context.rs b/src/librustpkg/context.rs
index db036f44a18..348d828bded 100644
--- a/src/librustpkg/context.rs
+++ b/src/librustpkg/context.rs
@@ -13,6 +13,9 @@
 use core::hashmap::HashMap;
 
 pub struct Ctx {
+    // Sysroot -- if this is None, uses rustc filesearch's
+    // idea of the default
+    sysroot_opt: Option<@Path>,
     // I'm not sure what this is for
     json: bool,
     // Cache of hashes of things already installed
diff --git a/src/librustpkg/path_util.rs b/src/librustpkg/path_util.rs
index 0490f066f0b..d21fdcda7f7 100644
--- a/src/librustpkg/path_util.rs
+++ b/src/librustpkg/path_util.rs
@@ -12,6 +12,7 @@
 
 use util::PkgId;
 use core::libc::consts::os::posix88::{S_IRUSR, S_IWUSR, S_IXUSR};
+use core::os::mkdir_recursive;
 
 #[deriving(Eq)]
 pub enum OutputType { Main, Lib, Bench, Test }
@@ -23,16 +24,12 @@ pub fn rust_path() -> ~[Path] {
     ~[Path(".")]
 }
 
-static u_rwx: i32 = (S_IRUSR | S_IWUSR | S_IXUSR) as i32;
+pub static u_rwx: i32 = (S_IRUSR | S_IWUSR | S_IXUSR) as i32;
 
 /// Creates a directory that is readable, writeable,
 /// and executable by the user. Returns true iff creation
 /// succeeded.
-pub fn make_dir_rwx(p: &Path) -> bool {
-    use core::libc::consts::os::posix88::{S_IRUSR, S_IWUSR, S_IXUSR};
-
-    os::make_dir(p, u_rwx)
-}
+pub fn make_dir_rwx(p: &Path) -> bool { os::make_dir(p, u_rwx) }
 
 /// Replace all occurrences of '-' in the stem part of path with '_'
 /// This is because we treat rust-foo-bar-quux and rust_foo_bar_quux
@@ -70,34 +67,137 @@ pub fn pkgid_src_in_workspace(pkgid: PkgId, workspace: &Path) -> Path {
     result.push(pkgid.path.to_str())
 }
 
+/// Figure out what the executable name for <pkgid> in <workspace>'s build
+/// directory is, and if the file exists, return it.
+pub fn built_executable_in_workspace(pkgid: PkgId, workspace: &Path) -> Option<Path> {
+    let mut result = workspace.push("build");
+    result = result.push_rel(&pkgid.path);
+    // should use a target-specific subdirectory
+    result = mk_output_path(Main, fmt!("%s-%s", pkgid.path.to_str(), pkgid.version.to_str()),
+                                       result);
+    debug!("built_executable_in_workspace: checking whether %s exists",
+           result.to_str());
+    if os::path_exists(&result) {
+        Some(result)
+    }
+    else {
+        None
+    }
+}
+
+/// Figure out what the library name for <pkgid> in <workspace>'s build
+/// directory is, and if the file exists, return it.
+pub fn built_library_in_workspace(pkgid: PkgId, workspace: &Path) -> Option<Path> {
+    let mut result = workspace.push("build");
+    result = result.push_rel(&pkgid.path);
+    // should use a target-specific subdirectory
+    result = mk_output_path(Lib, pkgid.path.to_str(), result);
+    debug!("built_library_in_workspace: checking whether %s exists",
+           result.to_str());
+
+    // We don't know what the hash is, so we have to search through the directory
+    // contents
+    let dir_contents = os::list_dir(&result.pop());
+    debug!("dir has %? entries", dir_contents.len());
+
+    // n.b. This code assumes the pkgid's path only has one element
+    let lib_prefix = fmt!("%s%s", os::consts::DLL_PREFIX, pkgid.path.to_str());
+    let lib_filetype = fmt!("%s%s", pkgid.version.to_str(), os::consts::DLL_SUFFIX);
+
+    debug!("lib_prefix = %s and lib_filetype = %s", lib_prefix, lib_filetype);
+
+    let mut result_filename = None;
+    for dir_contents.each |&p| {
+        let mut which = 0;
+        let mut hash = None;
+        // Find a filename that matches the pattern: (lib_prefix)-hash-(version)(lib_suffix)
+        // and remember what the hash was
+        for p.each_split_char('-') |piece| {
+            debug!("a piece = %s", piece);
+            if which == 0 && piece != lib_prefix {
+                break;
+            }
+            else if which == 0 {
+                which += 1;
+            }
+            else if which == 1 {
+                hash = Some(piece.to_owned());
+                which += 1;
+            }
+            else if which == 2 && piece != lib_filetype {
+                hash = None;
+                break;
+            }
+            else if which == 2 {
+                break;
+            }
+            else {
+                // something went wrong
+                hash = None;
+                break;
+            }
+        }
+        if hash.is_some() {
+            result_filename = Some(p);
+            break;
+        }
+    }
+
+    // Return the filename that matches, which we now know exists
+    // (if result_filename != None)
+    debug!("result_filename = %?", result_filename);
+    match result_filename {
+        None => None,
+        Some(result_filename) => {
+            let result_filename = result.with_filename(result_filename);
+            debug!("result_filename = %s", result_filename.to_str());
+            Some(result_filename)
+        }
+    }
+}
+
 /// Returns the executable that would be installed for <pkgid>
 /// in <workspace>
+/// As a side effect, creates the bin-dir if it doesn't exist
 pub fn target_executable_in_workspace(pkgid: PkgId, workspace: &Path) -> Path {
-    let result = workspace.push("bin");
-    // should use a target-specific subdirectory
-    mk_output_path(Main, pkgid.path.to_str(), result)
+    target_file_in_workspace(pkgid, workspace, Main)
 }
 
 
 /// Returns the executable that would be installed for <pkgid>
 /// in <workspace>
+/// As a side effect, creates the bin-dir if it doesn't exist
 pub fn target_library_in_workspace(pkgid: PkgId, workspace: &Path) -> Path {
-    let result = workspace.push("lib");
-    mk_output_path(Lib, pkgid.path.to_str(), result)
+    target_file_in_workspace(pkgid, workspace, Lib)
 }
 
 /// Returns the test executable that would be installed for <pkgid>
 /// in <workspace>
 pub fn target_test_in_workspace(pkgid: PkgId, workspace: &Path) -> Path {
-    let result = workspace.push("build");
-    mk_output_path(Test, pkgid.path.to_str(), result)
+    target_file_in_workspace(pkgid, workspace, Test)
 }
 
 /// Returns the bench executable that would be installed for <pkgid>
 /// in <workspace>
 pub fn target_bench_in_workspace(pkgid: PkgId, workspace: &Path) -> Path {
-    let result = workspace.push("build");
-    mk_output_path(Bench, pkgid.path.to_str(), result)
+    target_file_in_workspace(pkgid, workspace, Bench)
+}
+
+fn target_file_in_workspace(pkgid: PkgId, workspace: &Path,
+                            what: OutputType) -> Path {
+    use conditions::bad_path::cond;
+
+    let (subdir, create_dir) = match what {
+        Main => ("bin", true), Lib => ("lib", true), Test | Bench => ("build", false)
+    };
+    let result = workspace.push(subdir);
+    if create_dir {
+        if !os::path_exists(&result) && !mkdir_recursive(&result, u_rwx) {
+            cond.raise((result, fmt!("I couldn't create the %s dir", subdir)));
+        }
+    }
+    mk_output_path(what, pkgid.path.to_str(), result)
+
 }
 
 /// Return the directory for <pkgid>'s build artifacts in <workspace>.
@@ -123,7 +223,11 @@ pub fn mk_output_path(what: OutputType, short_name: ~str, dir: Path) -> Path {
     match what {
         Lib => dir.push(os::dll_filename(short_name)),
         _ => dir.push(fmt!("%s%s%s", short_name,
-                           if what == Test { ~"test" } else { ~"" },
+                           match what {
+                               Test => "test",
+                               Bench => "bench",
+                               _     => ""
+                           }
                            os::EXE_SUFFIX))
     }
 }
diff --git a/src/librustpkg/rustpkg.rc b/src/librustpkg/rustpkg.rc
index a296f0ca32a..dd5806ba015 100644
--- a/src/librustpkg/rustpkg.rc
+++ b/src/librustpkg/rustpkg.rc
@@ -34,6 +34,8 @@ use syntax::{ast, diagnostic};
 use util::*;
 use path_util::normalize;
 use path_util::{build_pkg_id_in_workspace, pkgid_src_in_workspace};
+use path_util::{built_executable_in_workspace, built_library_in_workspace};
+use path_util::{target_executable_in_workspace, target_library_in_workspace};
 use workspace::pkg_parent_workspaces;
 use rustc::driver::session::{lib_crate, bin_crate, crate_type};
 use context::Ctx;
@@ -188,49 +190,7 @@ impl Ctx {
                 // argument
                 let pkgid = PkgId::new(args[0]);
                 for pkg_parent_workspaces(pkgid) |workspace| {
-                    let src_dir   = pkgid_src_in_workspace(pkgid, workspace);
-                    let build_dir = build_pkg_id_in_workspace(pkgid, workspace);
-                    debug!("Destination dir = %s", build_dir.to_str());
-
-                    // Create the package source
-                    let mut src = PkgSrc::new(&workspace.push("src"), &build_dir, &pkgid);
-                    debug!("Package src = %?", src);
-
-                    // Is there custom build logic? If so, use it
-                    let pkg_src_dir = src_dir;
-                    let mut custom = false;
-                    debug!("Package source directory = %s", pkg_src_dir.to_str());
-                    let cfgs = match src.package_script_option(&pkg_src_dir) {
-                        Some(package_script_path) => {
-                            let pscript = PkgScript::parse(package_script_path,
-                                                           workspace,
-                                                           pkgid);
-                            // Limited right now -- we're only running the post_build
-                            // hook and probably fail otherwise
-                            // also post_build should be called pre_build
-                            let (cfgs, hook_result) = pscript.run_custom(~"post_build");
-                            debug!("Command return code = %?", hook_result);
-                            if hook_result != 0 {
-                                fail!(fmt!("Error running custom build command"))
-                            }
-                            custom = true;
-                            // otherwise, the package script succeeded
-                            cfgs
-                        }
-                        None => {
-                            debug!("No package script, continuing");
-                            ~[]
-                        }
-                    };
-
-                    // If there was a package script, it should have finished
-                    // the build already. Otherwise...
-                    if !custom {
-                        // Find crates inside the workspace
-                        src.find_crates();
-                        // Build it!
-                        src.build(&build_dir, cfgs);
-                    }
+                    self.build(workspace, pkgid);
                 }
             }
             ~"clean" => {
@@ -304,6 +264,53 @@ impl Ctx {
         fail!(~"`do` not yet implemented");
     }
 
+    fn build(&self, workspace: &Path, pkgid: PkgId) {
+        let src_dir   = pkgid_src_in_workspace(pkgid, workspace);
+        let build_dir = build_pkg_id_in_workspace(pkgid, workspace);
+        debug!("Destination dir = %s", build_dir.to_str());
+
+        // Create the package source
+        let mut src = PkgSrc::new(&workspace.push("src"), &build_dir, &pkgid);
+        debug!("Package src = %?", src);
+
+        // Is there custom build logic? If so, use it
+        let pkg_src_dir = src_dir;
+        let mut custom = false;
+        debug!("Package source directory = %s", pkg_src_dir.to_str());
+        let cfgs = match src.package_script_option(&pkg_src_dir) {
+            Some(package_script_path) => {
+                let pscript = PkgScript::parse(package_script_path,
+                                               workspace,
+                                               pkgid);
+                // Limited right now -- we're only running the post_build
+                // hook and probably fail otherwise
+                // also post_build should be called pre_build
+                let (cfgs, hook_result) = pscript.run_custom(~"post_build");
+                debug!("Command return code = %?", hook_result);
+                if hook_result != 0 {
+                    fail!(fmt!("Error running custom build command"))
+                }
+                custom = true;
+                // otherwise, the package script succeeded
+                cfgs
+            }
+            None => {
+                debug!("No package script, continuing");
+                ~[]
+            }
+        };
+
+        // If there was a package script, it should have finished
+        // the build already. Otherwise...
+        if !custom {
+            // Find crates inside the workspace
+            src.find_crates();
+            // Build it!
+            src.build(&build_dir, cfgs, self.sysroot_opt);
+        }
+
+    }
+
     fn clean(&self, workspace: &Path, id: PkgId)  {
         // Could also support a custom build hook in the pkg
         // script for cleaning files rustpkg doesn't know about.
@@ -325,9 +332,31 @@ impl Ctx {
         fail!(~"info not yet implemented");
     }
 
-    fn install(&self, _workspace: &Path, _id: PkgId)  {
-        // stub
-        fail!(~"install not yet implemented");
+    fn install(&self, workspace: &Path, id: PkgId)  {
+        use conditions::copy_failed::cond;
+
+        // Should use RUST_PATH in the future.
+        // Also should use workcache to not build if not necessary.
+        self.build(workspace, id);
+
+        // Now copy stuff into the install dirs
+        let maybe_executable = built_executable_in_workspace(id, workspace);
+        let maybe_library = built_library_in_workspace(id, workspace);
+        let target_exec = target_executable_in_workspace(id, workspace);
+        let target_lib = target_library_in_workspace(id, workspace);
+
+        for maybe_executable.each |exec| {
+            debug!("Copying: %s -> %s", exec.to_str(), target_exec.to_str());
+            if !os::copy_file(exec, &target_exec) {
+                cond.raise((*exec, target_exec));
+            }
+        }
+        for maybe_library.each |lib| {
+            debug!("Copying: %s -> %s", lib.to_str(), target_lib.to_str());
+            if !os::copy_file(lib, &target_lib) {
+                cond.raise((*lib, target_lib));
+            }
+        }
     }
 
     fn fetch(&self, _dir: &Path, _url: ~str, _target: Option<~str>)  {
@@ -477,6 +506,7 @@ pub fn main() {
     }
 
     Ctx {
+        sysroot_opt: None, // Currently, only tests override this
         json: json,
         dep_cache: @mut HashMap::new()
     }.run(cmd, args);
@@ -610,7 +640,7 @@ impl PkgSrc {
 
 
     fn check_dir(&self) -> Path {
-        use conditions::bad_path::cond;
+        use conditions::nonexistent_package::cond;
 
         debug!("Pushing onto root: %s | %s", self.id.path.to_str(),
                self.root.to_str());
@@ -619,13 +649,15 @@ impl PkgSrc {
 
         debug!("Checking dir: %s", dir.to_str());
 
+        // tjc: Rather than erroring out, need to try downloading the
+        // contents of the path to a local directory (#5679)
         if !os::path_exists(&dir) {
-            return cond.raise((dir, ~"missing package dir"));
+            cond.raise((self.id, ~"missing package dir"));
         }
 
         if !os::path_is_dir(&dir) {
-            return cond.raise((dir, ~"supplied path for package dir is a \
-                                      non-directory"));
+            cond.raise((self.id, ~"supplied path for package dir is a \
+                                   non-directory"));
         }
 
         dir
@@ -680,6 +712,7 @@ impl PkgSrc {
     /// is no custom build logic
     fn find_crates(&mut self) {
         use PkgSrc::push_crate;
+        use conditions::missing_pkg_files::cond;
 
         let dir = self.check_dir();
         let prefix = dir.components.len();
@@ -704,7 +737,7 @@ impl PkgSrc {
             util::note(~"Couldn't infer any crates to build.\n\
                          Try naming a crate `main.rs`, `lib.rs`, \
                          `test.rs`, or `bench.rs`.");
-            fail!(~"Failed to infer crates to build");
+            cond.raise(self.id);
         }
 
         debug!("found %u libs, %u mains, %u tests, %u benchs",
@@ -714,18 +747,20 @@ impl PkgSrc {
                self.benchs.len())
     }
 
-    fn build_crates(&self, dst_dir: &Path,
-                           src_dir: &Path,
-                           crates: &[Crate],
-                           cfgs: ~[~str],
-                           test: bool, crate_type: crate_type) {
+    fn build_crates(&self,
+                    maybe_sysroot: Option<@Path>,
+                    dst_dir: &Path,
+                    src_dir: &Path,
+                    crates: &[Crate],
+                    cfgs: ~[~str],
+                    test: bool, crate_type: crate_type) {
 
         for crates.each |&crate| {
             let path = &src_dir.push_rel(&crate.file).normalize();
             util::note(fmt!("build_crates: compiling %s", path.to_str()));
             util::note(fmt!("build_crates: destination dir is %s", dst_dir.to_str()));
 
-            let result = util::compile_crate(None, self.id, path,
+            let result = util::compile_crate(maybe_sysroot, self.id, path,
                                      dst_dir,
                                      crate.flags,
                                      crate.cfgs + cfgs,
@@ -739,15 +774,15 @@ impl PkgSrc {
         }
     }
 
-    fn build(&self, dst_dir: &Path, cfgs: ~[~str]) {
+    fn build(&self, dst_dir: &Path, cfgs: ~[~str], maybe_sysroot: Option<@Path>) {
         let dir = self.check_dir();
         debug!("Building libs");
-        self.build_crates(dst_dir, &dir, self.libs, cfgs, false, lib_crate);
+        self.build_crates(maybe_sysroot, dst_dir, &dir, self.libs, cfgs, false, lib_crate);
         debug!("Building mains");
-        self.build_crates(dst_dir, &dir, self.mains, cfgs, false, bin_crate);
+        self.build_crates(maybe_sysroot, dst_dir, &dir, self.mains, cfgs, false, bin_crate);
         debug!("Building tests");
-        self.build_crates(dst_dir, &dir, self.tests, cfgs, true, bin_crate);
+        self.build_crates(maybe_sysroot, dst_dir, &dir, self.tests, cfgs, true, bin_crate);
         debug!("Building benches");
-        self.build_crates(dst_dir, &dir, self.benchs, cfgs, true, bin_crate);
+        self.build_crates(maybe_sysroot, dst_dir, &dir, self.benchs, cfgs, true, bin_crate);
     }
 }
diff --git a/src/librustpkg/tests.rs b/src/librustpkg/tests.rs
index bcee2992e5a..486e2959e9e 100644
--- a/src/librustpkg/tests.rs
+++ b/src/librustpkg/tests.rs
@@ -17,10 +17,12 @@ use std::tempfile::mkdtemp;
 use util::{PkgId, default_version};
 use path_util::{target_executable_in_workspace, target_library_in_workspace,
                target_test_in_workspace, target_bench_in_workspace,
-               make_dir_rwx};
+               make_dir_rwx, u_rwx};
+use core::os::mkdir_recursive;
 
-fn fake_ctxt() -> Ctx {
+fn fake_ctxt(sysroot_opt: Option<@Path>) -> Ctx {
     Ctx {
+        sysroot_opt: sysroot_opt,
         json: false,
         dep_cache: @mut HashMap::new()
     }
@@ -33,8 +35,34 @@ fn fake_pkg() -> PkgId {
     }
 }
 
-fn mk_temp_workspace() -> Path {
-    mkdtemp(&os::tmpdir(), "test").expect("couldn't create temp dir")
+fn remote_pkg() -> PkgId {
+    PkgId {
+        path: Path(~"github.com/catamorphism/test-pkg"),
+        version: default_version()
+    }
+}
+
+fn writeFile(file_path: &Path, contents: ~str) {
+    let out: @io::Writer =
+        result::get(&io::file_writer(file_path,
+                                     ~[io::Create, io::Truncate]));
+    out.write_line(contents);
+}
+
+fn mk_temp_workspace(short_name: &Path) -> Path {
+    let workspace = mkdtemp(&os::tmpdir(), "test").expect("couldn't create temp dir");
+    let package_dir = workspace.push(~"src").push_rel(short_name);
+    assert!(mkdir_recursive(&package_dir, u_rwx));
+    // Create main, lib, test, and bench files
+    writeFile(&package_dir.push(~"main.rs"),
+              ~"fn main() { let _x = (); }");
+    writeFile(&package_dir.push(~"lib.rs"),
+              ~"pub fn f() { let _x = (); }");
+    writeFile(&package_dir.push(~"test.rs"),
+              ~"#[test] pub fn f() { (); }");
+    writeFile(&package_dir.push(~"bench.rs"),
+              ~"#[bench] pub fn f() { (); }");
+    workspace
 }
 
 fn is_rwx(p: &Path) -> bool {
@@ -42,60 +70,104 @@ fn is_rwx(p: &Path) -> bool {
 
     match p.get_mode() {
         None => return false,
-        Some(m) => {
+        Some(m) =>
             ((m & S_IRUSR as uint) == S_IRUSR as uint
             && (m & S_IWUSR as uint) == S_IWUSR as uint
             && (m & S_IXUSR as uint) == S_IXUSR as uint)
-        }
     }
 }
 
+#[cfg(test)]
+fn test_sysroot() -> Path {
+    // Totally gross hack but it's just for test cases.
+    // Infer the sysroot from the exe name and tack "stage2"
+    // onto it. (Did I mention it was a gross hack?)
+    let self_path = os::self_exe_path().expect("Couldn't get self_exe path");
+    self_path.pop().push("stage2")
+}
+
 #[test]
 fn test_make_dir_rwx() {
     let temp = &os::tmpdir();
     let dir = temp.push(~"quux");
-    let _ = os::remove_dir(&dir);
+    assert!(!os::path_exists(&dir) ||
+            os::remove_dir_recursive(&dir));
+    debug!("Trying to make %s", dir.to_str());
     assert!(make_dir_rwx(&dir));
     assert!(os::path_is_dir(&dir));
     assert!(is_rwx(&dir));
-    assert!(os::remove_dir(&dir));
+    assert!(os::remove_dir_recursive(&dir));
 }
 
 #[test]
-#[ignore(reason = "install not yet implemented")]
 fn test_install_valid() {
-    let ctxt = fake_ctxt();
+    let sysroot = test_sysroot();
+    debug!("sysroot = %s", sysroot.to_str());
+    let ctxt = fake_ctxt(Some(@sysroot));
     let temp_pkg_id = fake_pkg();
-    let temp_workspace = mk_temp_workspace();
+    let temp_workspace = mk_temp_workspace(&temp_pkg_id.path);
     // should have test, bench, lib, and main
     ctxt.install(&temp_workspace, temp_pkg_id);
     // Check that all files exist
     let exec = target_executable_in_workspace(temp_pkg_id, &temp_workspace);
+    debug!("exec = %s", exec.to_str());
     assert!(os::path_exists(&exec));
     assert!(is_rwx(&exec));
     let lib = target_library_in_workspace(temp_pkg_id, &temp_workspace);
+    debug!("lib = %s", lib.to_str());
     assert!(os::path_exists(&lib));
     assert!(is_rwx(&lib));
     // And that the test and bench executables aren't installed
     assert!(!os::path_exists(&target_test_in_workspace(temp_pkg_id, &temp_workspace)));
-    assert!(!os::path_exists(&target_bench_in_workspace(temp_pkg_id, &temp_workspace)));
+    let bench = target_bench_in_workspace(temp_pkg_id, &temp_workspace);
+    debug!("bench = %s", bench.to_str());
+    assert!(!os::path_exists(&bench));
 }
 
 #[test]
-#[ignore(reason = "install not yet implemented")]
 fn test_install_invalid() {
     use conditions::nonexistent_package::cond;
+    use cond1 = conditions::missing_pkg_files::cond;
 
-    let ctxt = fake_ctxt();
+    let ctxt = fake_ctxt(None);
     let pkgid = fake_pkg();
-    let temp_workspace = mk_temp_workspace();
-    let expected_path = Path(~"quux");
-    let substituted: Path = do cond.trap(|_| {
-        expected_path
+    let temp_workspace = mkdtemp(&os::tmpdir(), "test").expect("couldn't create temp dir");
+    let mut error_occurred = false;
+    let mut error1_occurred = false;
+    do cond1.trap(|_| {
+        error1_occurred = true;
     }).in {
-        ctxt.install(&temp_workspace, pkgid);
-        // ok
-        fail!(~"test_install_invalid failed, should have raised a condition");
-    };
-    assert!(substituted == expected_path);
+        do cond.trap(|_| {
+            error_occurred = true;
+        }).in {
+            ctxt.install(&temp_workspace, pkgid);
+        }
+    }
+    assert!(error_occurred && error1_occurred);
 }
+
+#[test]
+#[ignore(reason = "install from URL-fragment not yet implemented")]
+fn test_install_url() {
+    let sysroot = test_sysroot();
+    debug!("sysroot = %s", sysroot.to_str());
+    let ctxt = fake_ctxt(Some(@sysroot));
+    let temp_pkg_id = remote_pkg();
+    let temp_workspace = mk_temp_workspace(&temp_pkg_id.path);
+    // should have test, bench, lib, and main
+    ctxt.install(&temp_workspace, temp_pkg_id);
+    // Check that all files exist
+    let exec = target_executable_in_workspace(temp_pkg_id, &temp_workspace);
+    debug!("exec = %s", exec.to_str());
+    assert!(os::path_exists(&exec));
+    assert!(is_rwx(&exec));
+    let lib = target_library_in_workspace(temp_pkg_id, &temp_workspace);
+    debug!("lib = %s", lib.to_str());
+    assert!(os::path_exists(&lib));
+    assert!(is_rwx(&lib));
+    // And that the test and bench executables aren't installed
+    assert!(!os::path_exists(&target_test_in_workspace(temp_pkg_id, &temp_workspace)));
+    let bench = target_bench_in_workspace(temp_pkg_id, &temp_workspace);
+    debug!("bench = %s", bench.to_str());
+    assert!(!os::path_exists(&bench));
+}
\ No newline at end of file
diff --git a/src/librustpkg/testsuite/pass/commands.txt b/src/librustpkg/testsuite/pass/commands.txt
index e1a1b2462b2..baeaef1e3c7 100644
--- a/src/librustpkg/testsuite/pass/commands.txt
+++ b/src/librustpkg/testsuite/pass/commands.txt
@@ -32,4 +32,3 @@ Commands that should succeed:
 15. `rustpkg test foo` runs tests and prints their output, if foo contains #[test]s.
 
 16. If foo is installed, `rustpkg uninstall foo; rustpkg list` doesn't include foo in the list
-
diff --git a/src/librustpkg/testsuite/pass/src/deeply/nested/path/foo/src/main.rs b/src/librustpkg/testsuite/pass/src/deeply/nested/path/foo/src/main.rs
index 41041ccb509..62785c06db3 100644
--- a/src/librustpkg/testsuite/pass/src/deeply/nested/path/foo/src/main.rs
+++ b/src/librustpkg/testsuite/pass/src/deeply/nested/path/foo/src/main.rs
@@ -15,4 +15,3 @@ The test runner should check that, after `rustpkg install deeply/nested/path/foo
 */
 
 fn main() {}
-
diff --git a/src/librustpkg/util.rs b/src/librustpkg/util.rs
index 28198e59f86..0762fa4ad7f 100644
--- a/src/librustpkg/util.rs
+++ b/src/librustpkg/util.rs
@@ -435,7 +435,7 @@ pub fn add_pkg(pkg: &Pkg) -> bool {
 }
 
 // FIXME (#4432): Use workcache to only compile when needed
-pub fn compile_input(sysroot: Option<Path>,
+pub fn compile_input(sysroot: Option<@Path>,
                      pkg_id: PkgId,
                      in_file: &Path,
                      out_dir: &Path,
@@ -474,9 +474,12 @@ pub fn compile_input(sysroot: Option<Path>,
            out_file.to_str());
     debug!("flags: %s", str::connect(flags, ~" "));
     debug!("cfgs: %s", str::connect(cfgs, ~" "));
+    debug!("compile_input's sysroot = %?", sysroot);
 
     let matches = getopts(~[~"-Z", ~"time-passes"]
                           + if building_library { ~[~"--lib"] }
+                            else if test { ~[~"--test"] }
+                            // bench?
                             else { ~[] }
                           + flags
                           + cfgs.flat_map(|&c| { ~[~"--cfg", c] }),
@@ -540,9 +543,13 @@ pub fn compile_crate_from_input(input: driver::input,
             let (crate, _) = driver::compile_upto(sess, cfg, &input,
                                                   driver::cu_parse, Some(outputs));
 
+            debug!("About to inject link_meta info...");
             // Inject the inferred link_meta info if it's not already there
             // (assumes that name and vers are the only linkage metas)
             let mut crate_to_use = crate;
+
+            debug!("How many attrs? %?", attr::find_linkage_metas(crate.node.attrs).len());
+
             if attr::find_linkage_metas(crate.node.attrs).is_empty() {
                 crate_to_use = add_attrs(*crate, ~[mk_attr(@dummy_spanned(meta_list(@~"link",
                                                   // change PkgId to have a <shortname> field?
@@ -552,7 +559,6 @@ pub fn compile_crate_from_input(input: driver::input,
                                                     mk_string_lit(@pkg_id.version.to_str())))])))]);
             }
 
-
             driver::compile_rest(sess, cfg, what, Some(outputs), Some(crate_to_use));
             crate_to_use
         }
@@ -582,7 +588,7 @@ fn add_attrs(c: ast::crate, new_attrs: ~[attribute]) -> @ast::crate {
 
 // Called by build_crates
 // FIXME (#4432): Use workcache to only compile when needed
-pub fn compile_crate(sysroot: Option<Path>, pkg_id: PkgId,
+pub fn compile_crate(sysroot: Option<@Path>, pkg_id: PkgId,
                      crate: &Path, dir: &Path,
                      flags: ~[~str], cfgs: ~[~str], opt: bool,
                      test: bool, crate_type: crate_type) -> bool {
diff --git a/src/libstd/arena.rs b/src/libstd/arena.rs
index e714af5fa18..b9a09323f81 100644
--- a/src/libstd/arena.rs
+++ b/src/libstd/arena.rs
@@ -32,11 +32,10 @@
 // overhead when initializing plain-old-data and means we don't need
 // to waste time running the destructors of POD.
 
-use list;
-use list::{List, Cons, Nil};
+use list::{MutList, MutCons, MutNil};
 
 use core::at_vec;
-use core::cast::transmute;
+use core::cast::{transmute, transmute_mut_region};
 use core::cast;
 use core::libc::size_t;
 use core::ptr;
@@ -74,17 +73,17 @@ static tydesc_drop_glue_index: size_t = 3 as size_t;
 // will always stay at 0.
 struct Chunk {
     data: @[u8],
-    mut fill: uint,
+    fill: uint,
     is_pod: bool,
 }
 
 pub struct Arena {
-    // The head is seperated out from the list as a unbenchmarked
+    // The head is separated out from the list as a unbenchmarked
     // microoptimization, to avoid needing to case on the list to
     // access the head.
-    priv mut head: Chunk,
-    priv mut pod_head: Chunk,
-    priv mut chunks: @List<Chunk>,
+    priv head: Chunk,
+    priv pod_head: Chunk,
+    priv chunks: @mut MutList<Chunk>,
 }
 
 #[unsafe_destructor]
@@ -92,8 +91,10 @@ impl Drop for Arena {
     fn finalize(&self) {
         unsafe {
             destroy_chunk(&self.head);
-            for list::each(self.chunks) |chunk| {
-                if !chunk.is_pod { destroy_chunk(chunk); }
+            for self.chunks.each |chunk| {
+                if !chunk.is_pod {
+                    destroy_chunk(chunk);
+                }
             }
         }
     }
@@ -113,7 +114,7 @@ pub fn arena_with_size(initial_size: uint) -> Arena {
     Arena {
         head: chunk(initial_size, false),
         pod_head: chunk(initial_size, true),
-        chunks: @Nil,
+        chunks: @mut MutNil,
     }
 }
 
@@ -170,11 +171,11 @@ unsafe fn un_bitpack_tydesc_ptr(p: uint) -> (*TypeDesc, bool) {
 
 pub impl Arena {
     // Functions for the POD part of the arena
-    priv fn alloc_pod_grow(&self, n_bytes: uint, align: uint) -> *u8 {
+    priv fn alloc_pod_grow(&mut self, n_bytes: uint, align: uint) -> *u8 {
         // Allocate a new chunk.
         let chunk_size = at_vec::capacity(self.pod_head.data);
         let new_min_chunk_size = uint::max(n_bytes, chunk_size);
-        self.chunks = @Cons(copy self.pod_head, self.chunks);
+        self.chunks = @mut MutCons(copy self.pod_head, self.chunks);
         self.pod_head =
             chunk(uint::next_power_of_two(new_min_chunk_size + 1u), true);
 
@@ -182,26 +183,27 @@ pub impl Arena {
     }
 
     #[inline(always)]
-    priv fn alloc_pod_inner(&self, n_bytes: uint, align: uint) -> *u8 {
-        let head = &mut self.pod_head;
+    priv fn alloc_pod_inner(&mut self, n_bytes: uint, align: uint) -> *u8 {
+        unsafe {
+            // XXX: Borrow check
+            let head = transmute_mut_region(&mut self.pod_head);
 
-        let start = round_up_to(head.fill, align);
-        let end = start + n_bytes;
-        if end > at_vec::capacity(head.data) {
-            return self.alloc_pod_grow(n_bytes, align);
-        }
-        head.fill = end;
+            let start = round_up_to(head.fill, align);
+            let end = start + n_bytes;
+            if end > at_vec::capacity(head.data) {
+                return self.alloc_pod_grow(n_bytes, align);
+            }
+            head.fill = end;
 
-        //debug!("idx = %u, size = %u, align = %u, fill = %u",
-        //       start, n_bytes, align, head.fill);
+            //debug!("idx = %u, size = %u, align = %u, fill = %u",
+            //       start, n_bytes, align, head.fill);
 
-        unsafe {
             ptr::offset(vec::raw::to_ptr(head.data), start)
         }
     }
 
     #[inline(always)]
-    priv fn alloc_pod<'a, T>(&'a self, op: &fn() -> T) -> &'a T {
+    priv fn alloc_pod<'a, T>(&'a mut self, op: &fn() -> T) -> &'a T {
         unsafe {
             let tydesc = sys::get_type_desc::<T>();
             let ptr = self.alloc_pod_inner((*tydesc).size, (*tydesc).align);
@@ -212,11 +214,12 @@ pub impl Arena {
     }
 
     // Functions for the non-POD part of the arena
-    priv fn alloc_nonpod_grow(&self, n_bytes: uint, align: uint) -> (*u8, *u8) {
+    priv fn alloc_nonpod_grow(&mut self, n_bytes: uint, align: uint)
+                             -> (*u8, *u8) {
         // Allocate a new chunk.
         let chunk_size = at_vec::capacity(self.head.data);
         let new_min_chunk_size = uint::max(n_bytes, chunk_size);
-        self.chunks = @Cons(copy self.head, self.chunks);
+        self.chunks = @mut MutCons(copy self.head, self.chunks);
         self.head =
             chunk(uint::next_power_of_two(new_min_chunk_size + 1u), false);
 
@@ -224,29 +227,30 @@ pub impl Arena {
     }
 
     #[inline(always)]
-    priv fn alloc_nonpod_inner(&self, n_bytes: uint, align: uint) -> (*u8, *u8) {
-        let head = &mut self.head;
-
-        let tydesc_start = head.fill;
-        let after_tydesc = head.fill + sys::size_of::<*TypeDesc>();
-        let start = round_up_to(after_tydesc, align);
-        let end = start + n_bytes;
-        if end > at_vec::capacity(head.data) {
-            return self.alloc_nonpod_grow(n_bytes, align);
-        }
-        head.fill = round_up_to(end, sys::pref_align_of::<*TypeDesc>());
+    priv fn alloc_nonpod_inner(&mut self, n_bytes: uint, align: uint)
+                               -> (*u8, *u8) {
+        unsafe {
+            let head = transmute_mut_region(&mut self.head);
+
+            let tydesc_start = head.fill;
+            let after_tydesc = head.fill + sys::size_of::<*TypeDesc>();
+            let start = round_up_to(after_tydesc, align);
+            let end = start + n_bytes;
+            if end > at_vec::capacity(head.data) {
+                return self.alloc_nonpod_grow(n_bytes, align);
+            }
+            head.fill = round_up_to(end, sys::pref_align_of::<*TypeDesc>());
 
-        //debug!("idx = %u, size = %u, align = %u, fill = %u",
-        //       start, n_bytes, align, head.fill);
+            //debug!("idx = %u, size = %u, align = %u, fill = %u",
+            //       start, n_bytes, align, head.fill);
 
-        unsafe {
             let buf = vec::raw::to_ptr(head.data);
             return (ptr::offset(buf, tydesc_start), ptr::offset(buf, start));
         }
     }
 
     #[inline(always)]
-    priv fn alloc_nonpod<'a, T>(&'a self, op: &fn() -> T) -> &'a T {
+    priv fn alloc_nonpod<'a, T>(&'a mut self, op: &fn() -> T) -> &'a T {
         unsafe {
             let tydesc = sys::get_type_desc::<T>();
             let (ty_ptr, ptr) =
@@ -268,20 +272,23 @@ pub impl Arena {
 
     // The external interface
     #[inline(always)]
-    fn alloc<'a, T>(&'a self, op: &fn() -> T) -> &'a T {
+    fn alloc<'a, T>(&'a mut self, op: &fn() -> T) -> &'a T {
         unsafe {
+            // XXX: Borrow check
+            let this = transmute_mut_region(self);
             if !rusti::needs_drop::<T>() {
-                self.alloc_pod(op)
-            } else {
-                self.alloc_nonpod(op)
+                return this.alloc_pod(op);
             }
+            // XXX: Borrow check
+            let this = transmute_mut_region(self);
+            this.alloc_nonpod(op)
         }
     }
 }
 
 #[test]
 fn test_arena_destructors() {
-    let arena = Arena();
+    let mut arena = Arena();
     for uint::range(0, 10) |i| {
         // Arena allocate something with drop glue to make sure it
         // doesn't leak.
@@ -292,9 +299,11 @@ fn test_arena_destructors() {
     }
 }
 
-#[test] #[should_fail] #[ignore(cfg(windows))]
+#[test]
+#[should_fail]
+#[ignore(cfg(windows))]
 fn test_arena_destructors_fail() {
-    let arena = Arena();
+    let mut arena = Arena();
     // Put some stuff in the arena.
     for uint::range(0, 10) |i| {
         // Arena allocate something with drop glue to make sure it
diff --git a/src/libstd/bitv.rs b/src/libstd/bitv.rs
index d48d7af354b..ceb67fcabfa 100644
--- a/src/libstd/bitv.rs
+++ b/src/libstd/bitv.rs
@@ -1507,13 +1507,3 @@ mod tests {
         }
     }
 }
-
-//
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
-//
diff --git a/src/libstd/cmp.rs b/src/libstd/cmp.rs
index 5d7f64a7c8f..ea3793c1374 100644
--- a/src/libstd/cmp.rs
+++ b/src/libstd/cmp.rs
@@ -64,7 +64,7 @@ fn test_fuzzy_eq_eps() {
     assert!(!(&1.5f).fuzzy_eq_eps(&0.9, &0.5));
 }
 
-#[test]
+#[cfg(test)]
 mod test_complex{
     use cmp::*;
 
diff --git a/src/libstd/dbg.rs b/src/libstd/dbg.rs
index 34dd6390ecc..4b2d2a60a68 100644
--- a/src/libstd/dbg.rs
+++ b/src/libstd/dbg.rs
@@ -76,11 +76,3 @@ fn test_breakpoint_should_not_abort_process_when_not_under_gdb() {
     // the process under normal circumstances
     breakpoint();
 }
-
-// Local Variables:
-// mode: rust;
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
diff --git a/src/libstd/deque.rs b/src/libstd/deque.rs
index 64d708e0b2e..65e71869a1f 100644
--- a/src/libstd/deque.rs
+++ b/src/libstd/deque.rs
@@ -231,7 +231,7 @@ mod tests {
         assert!(*deq.get(3) == d);
     }
 
-    #[test]
+    #[cfg(test)]
     fn test_parameterized<T:Copy + Eq + Durable>(a: T, b: T, c: T, d: T) {
         let mut deq = Deque::new();
         assert!(deq.len() == 0);
diff --git a/src/libstd/ebml.rs b/src/libstd/ebml.rs
index 65ce9d8989f..864a49a1429 100644
--- a/src/libstd/ebml.rs
+++ b/src/libstd/ebml.rs
@@ -36,13 +36,27 @@ pub struct TaggedDoc {
 }
 
 pub enum EbmlEncoderTag {
-    EsUint, EsU64, EsU32, EsU16, EsU8,
-    EsInt, EsI64, EsI32, EsI16, EsI8,
-    EsBool,
-    EsStr,
-    EsF64, EsF32, EsFloat,
-    EsEnum, EsEnumVid, EsEnumBody,
-    EsVec, EsVecLen, EsVecElt,
+    EsUint,     // 0
+    EsU64,      // 1
+    EsU32,      // 2
+    EsU16,      // 3
+    EsU8,       // 4
+    EsInt,      // 5
+    EsI64,      // 6
+    EsI32,      // 7
+    EsI16,      // 8
+    EsI8,       // 9
+    EsBool,     // 10
+    EsStr,      // 11
+    EsF64,      // 12
+    EsF32,      // 13
+    EsFloat,    // 14
+    EsEnum,     // 15
+    EsEnumVid,  // 16
+    EsEnumBody, // 17
+    EsVec,      // 18
+    EsVecLen,   // 19
+    EsVecElt,   // 20
 
     EsOpaque,
 
@@ -249,18 +263,20 @@ pub mod reader {
     pub fn doc_as_i32(d: Doc) -> i32 { doc_as_u32(d) as i32 }
     pub fn doc_as_i64(d: Doc) -> i64 { doc_as_u64(d) as i64 }
 
-
     pub struct Decoder {
-        priv mut parent: Doc,
-        priv mut pos: uint,
+        priv parent: Doc,
+        priv pos: uint,
     }
 
     pub fn Decoder(d: Doc) -> Decoder {
-        Decoder { parent: d, pos: d.start }
+        Decoder {
+            parent: d,
+            pos: d.start
+        }
     }
 
     priv impl Decoder {
-        fn _check_label(&self, lbl: &str) {
+        fn _check_label(&mut self, lbl: &str) {
             if self.pos < self.parent.end {
                 let TaggedDoc { tag: r_tag, doc: r_doc } =
                     doc_at(self.parent.data, self.pos);
@@ -269,14 +285,15 @@ pub mod reader {
                     self.pos = r_doc.end;
                     let str = doc_as_str(r_doc);
                     if lbl != str {
-                        fail!(fmt!("Expected label %s but found %s", lbl,
-                            str));
+                        fail!(fmt!("Expected label %s but found %s",
+                                   lbl,
+                                   str));
                     }
                 }
             }
         }
 
-        fn next_doc(&self, exp_tag: EbmlEncoderTag) -> Doc {
+        fn next_doc(&mut self, exp_tag: EbmlEncoderTag) -> Doc {
             debug!(". next_doc(exp_tag=%?)", exp_tag);
             if self.pos >= self.parent.end {
                 fail!(~"no more documents in current node!");
@@ -298,7 +315,7 @@ pub mod reader {
             r_doc
         }
 
-        fn push_doc<T>(&self, d: Doc, f: &fn() -> T) -> T {
+        fn push_doc<T>(&mut self, d: Doc, f: &fn() -> T) -> T {
             let old_parent = self.parent;
             let old_pos = self.pos;
             self.parent = d;
@@ -309,7 +326,7 @@ pub mod reader {
             r
         }
 
-        fn _next_uint(&self, exp_tag: EbmlEncoderTag) -> uint {
+        fn _next_uint(&mut self, exp_tag: EbmlEncoderTag) -> uint {
             let r = doc_as_u32(self.next_doc(exp_tag));
             debug!("_next_uint exp_tag=%? result=%?", exp_tag, r);
             r as uint
@@ -317,21 +334,29 @@ pub mod reader {
     }
 
     pub impl Decoder {
-        fn read_opaque<R>(&self, op: &fn(Doc) -> R) -> R {
-            do self.push_doc(self.next_doc(EsOpaque)) {
-                op(copy self.parent)
-            }
+        fn read_opaque<R>(&mut self, op: &fn(&mut Decoder, Doc) -> R) -> R {
+            let doc = self.next_doc(EsOpaque);
+
+            let (old_parent, old_pos) = (self.parent, self.pos);
+            self.parent = doc;
+            self.pos = doc.start;
+
+            let result = op(self, doc);
+
+            self.parent = old_parent;
+            self.pos = old_pos;
+            result
         }
     }
 
     impl serialize::Decoder for Decoder {
-        fn read_nil(&self) -> () { () }
+        fn read_nil(&mut self) -> () { () }
 
-        fn read_u64(&self) -> u64 { doc_as_u64(self.next_doc(EsU64)) }
-        fn read_u32(&self) -> u32 { doc_as_u32(self.next_doc(EsU32)) }
-        fn read_u16(&self) -> u16 { doc_as_u16(self.next_doc(EsU16)) }
-        fn read_u8 (&self) -> u8  { doc_as_u8 (self.next_doc(EsU8 )) }
-        fn read_uint(&self) -> uint {
+        fn read_u64(&mut self) -> u64 { doc_as_u64(self.next_doc(EsU64)) }
+        fn read_u32(&mut self) -> u32 { doc_as_u32(self.next_doc(EsU32)) }
+        fn read_u16(&mut self) -> u16 { doc_as_u16(self.next_doc(EsU16)) }
+        fn read_u8 (&mut self) -> u8  { doc_as_u8 (self.next_doc(EsU8 )) }
+        fn read_uint(&mut self) -> uint {
             let v = doc_as_u64(self.next_doc(EsUint));
             if v > (::core::uint::max_value as u64) {
                 fail!(fmt!("uint %? too large for this architecture", v));
@@ -339,11 +364,19 @@ pub mod reader {
             v as uint
         }
 
-        fn read_i64(&self) -> i64 { doc_as_u64(self.next_doc(EsI64)) as i64 }
-        fn read_i32(&self) -> i32 { doc_as_u32(self.next_doc(EsI32)) as i32 }
-        fn read_i16(&self) -> i16 { doc_as_u16(self.next_doc(EsI16)) as i16 }
-        fn read_i8 (&self) -> i8  { doc_as_u8 (self.next_doc(EsI8 )) as i8  }
-        fn read_int(&self) -> int {
+        fn read_i64(&mut self) -> i64 {
+            doc_as_u64(self.next_doc(EsI64)) as i64
+        }
+        fn read_i32(&mut self) -> i32 {
+            doc_as_u32(self.next_doc(EsI32)) as i32
+        }
+        fn read_i16(&mut self) -> i16 {
+            doc_as_u16(self.next_doc(EsI16)) as i16
+        }
+        fn read_i8 (&mut self) -> i8 {
+            doc_as_u8(self.next_doc(EsI8 )) as i8
+        }
+        fn read_int(&mut self) -> int {
             let v = doc_as_u64(self.next_doc(EsInt)) as i64;
             if v > (int::max_value as i64) || v < (int::min_value as i64) {
                 fail!(fmt!("int %? out of range for this architecture", v));
@@ -351,119 +384,204 @@ pub mod reader {
             v as int
         }
 
-        fn read_bool(&self) -> bool { doc_as_u8(self.next_doc(EsBool))
-                                         as bool }
+        fn read_bool(&mut self) -> bool {
+            doc_as_u8(self.next_doc(EsBool)) as bool
+        }
 
-        fn read_f64(&self) -> f64 { fail!(~"read_f64()"); }
-        fn read_f32(&self) -> f32 { fail!(~"read_f32()"); }
-        fn read_float(&self) -> float { fail!(~"read_float()"); }
-        fn read_char(&self) -> char { fail!(~"read_char()"); }
-        fn read_str(&self) -> ~str { doc_as_str(self.next_doc(EsStr)) }
+        fn read_f64(&mut self) -> f64 { fail!(~"read_f64()"); }
+        fn read_f32(&mut self) -> f32 { fail!(~"read_f32()"); }
+        fn read_float(&mut self) -> float { fail!(~"read_float()"); }
+        fn read_char(&mut self) -> char { fail!(~"read_char()"); }
+        fn read_str(&mut self) -> ~str { doc_as_str(self.next_doc(EsStr)) }
 
         // Compound types:
-        fn read_enum<T>(&self, name: &str, f: &fn() -> T) -> T {
+        fn read_enum<T>(&mut self,
+                        name: &str,
+                        f: &fn(&mut Decoder) -> T)
+                        -> T {
             debug!("read_enum(%s)", name);
             self._check_label(name);
-            self.push_doc(self.next_doc(EsEnum), f)
+
+            let doc = self.next_doc(EsEnum);
+
+            let (old_parent, old_pos) = (self.parent, self.pos);
+            self.parent = doc;
+            self.pos = self.parent.start;
+
+            let result = f(self);
+
+            self.parent = old_parent;
+            self.pos = old_pos;
+            result
         }
 
-        fn read_enum_variant<T>(&self, _names: &[&str], f: &fn(uint) -> T) -> T {
+        fn read_enum_variant<T>(&mut self,
+                                _: &[&str],
+                                f: &fn(&mut Decoder, uint) -> T)
+                                -> T {
             debug!("read_enum_variant()");
             let idx = self._next_uint(EsEnumVid);
             debug!("  idx=%u", idx);
-            do self.push_doc(self.next_doc(EsEnumBody)) {
-                f(idx)
-            }
+
+            let doc = self.next_doc(EsEnumBody);
+
+            let (old_parent, old_pos) = (self.parent, self.pos);
+            self.parent = doc;
+            self.pos = self.parent.start;
+
+            let result = f(self, idx);
+
+            self.parent = old_parent;
+            self.pos = old_pos;
+            result
         }
 
-        fn read_enum_variant_arg<T>(&self, idx: uint, f: &fn() -> T) -> T {
+        fn read_enum_variant_arg<T>(&mut self,
+                                    idx: uint,
+                                    f: &fn(&mut Decoder) -> T) -> T {
             debug!("read_enum_variant_arg(idx=%u)", idx);
-            f()
+            f(self)
         }
 
-        fn read_enum_struct_variant<T>(&self, _names: &[&str], f: &fn(uint) -> T) -> T {
+        fn read_enum_struct_variant<T>(&mut self,
+                                       _: &[&str],
+                                       f: &fn(&mut Decoder, uint) -> T)
+                                       -> T {
             debug!("read_enum_struct_variant()");
             let idx = self._next_uint(EsEnumVid);
             debug!("  idx=%u", idx);
-            do self.push_doc(self.next_doc(EsEnumBody)) {
-                f(idx)
-            }
+
+            let doc = self.next_doc(EsEnumBody);
+
+            let (old_parent, old_pos) = (self.parent, self.pos);
+            self.parent = doc;
+            self.pos = self.parent.start;
+
+            let result = f(self, idx);
+
+            self.parent = old_parent;
+            self.pos = old_pos;
+            result
         }
 
-        fn read_enum_struct_variant_field<T>(&self, name: &str, idx: uint, f: &fn() -> T) -> T {
+        fn read_enum_struct_variant_field<T>(&mut self,
+                                             name: &str,
+                                             idx: uint,
+                                             f: &fn(&mut Decoder) -> T)
+                                             -> T {
             debug!("read_enum_struct_variant_arg(name=%?, idx=%u)", name, idx);
-            f()
+            f(self)
         }
 
-        fn read_struct<T>(&self, name: &str, _len: uint, f: &fn() -> T) -> T {
+        fn read_struct<T>(&mut self,
+                          name: &str,
+                          _: uint,
+                          f: &fn(&mut Decoder) -> T)
+                          -> T {
             debug!("read_struct(name=%s)", name);
-            f()
+            f(self)
         }
 
-        fn read_struct_field<T>(&self, name: &str, idx: uint, f: &fn() -> T) -> T {
+        fn read_struct_field<T>(&mut self,
+                                name: &str,
+                                idx: uint,
+                                f: &fn(&mut Decoder) -> T)
+                                -> T {
             debug!("read_struct_field(name=%?, idx=%u)", name, idx);
             self._check_label(name);
-            f()
+            f(self)
         }
 
-        fn read_tuple<T>(&self, f: &fn(uint) -> T) -> T {
+        fn read_tuple<T>(&mut self, f: &fn(&mut Decoder, uint) -> T) -> T {
             debug!("read_tuple()");
             self.read_seq(f)
         }
 
-        fn read_tuple_arg<T>(&self, idx: uint, f: &fn() -> T) -> T {
+        fn read_tuple_arg<T>(&mut self, idx: uint, f: &fn(&mut Decoder) -> T)
+                             -> T {
             debug!("read_tuple_arg(idx=%u)", idx);
             self.read_seq_elt(idx, f)
         }
 
-        fn read_tuple_struct<T>(&self, name: &str, f: &fn(uint) -> T) -> T {
+        fn read_tuple_struct<T>(&mut self,
+                                name: &str,
+                                f: &fn(&mut Decoder, uint) -> T)
+                                -> T {
             debug!("read_tuple_struct(name=%?)", name);
             self.read_tuple(f)
         }
 
-        fn read_tuple_struct_arg<T>(&self, idx: uint, f: &fn() -> T) -> T {
+        fn read_tuple_struct_arg<T>(&mut self,
+                                    idx: uint,
+                                    f: &fn(&mut Decoder) -> T)
+                                    -> T {
             debug!("read_tuple_struct_arg(idx=%u)", idx);
             self.read_tuple_arg(idx, f)
         }
 
-        fn read_option<T>(&self, f: &fn(bool) -> T) -> T {
+        fn read_option<T>(&mut self, f: &fn(&mut Decoder, bool) -> T) -> T {
             debug!("read_option()");
-            do self.read_enum("Option") || {
-                do self.read_enum_variant(["None", "Some"]) |idx| {
+            do self.read_enum("Option") |this| {
+                do this.read_enum_variant(["None", "Some"]) |this, idx| {
                     match idx {
-                        0 => f(false),
-                        1 => f(true),
+                        0 => f(this, false),
+                        1 => f(this, true),
                         _ => fail!(),
                     }
                 }
             }
         }
 
-        fn read_seq<T>(&self, f: &fn(uint) -> T) -> T {
+        fn read_seq<T>(&mut self, f: &fn(&mut Decoder, uint) -> T) -> T {
             debug!("read_seq()");
-            do self.push_doc(self.next_doc(EsVec)) {
-                let len = self._next_uint(EsVecLen);
-                debug!("  len=%u", len);
-                f(len)
-            }
+            let doc = self.next_doc(EsVec);
+
+            let (old_parent, old_pos) = (self.parent, self.pos);
+            self.parent = doc;
+            self.pos = self.parent.start;
+
+            let len = self._next_uint(EsVecLen);
+            debug!("  len=%u", len);
+            let result = f(self, len);
+
+            self.parent = old_parent;
+            self.pos = old_pos;
+            result
         }
 
-        fn read_seq_elt<T>(&self, idx: uint, f: &fn() -> T) -> T {
+        fn read_seq_elt<T>(&mut self, idx: uint, f: &fn(&mut Decoder) -> T)
+                           -> T {
             debug!("read_seq_elt(idx=%u)", idx);
-            self.push_doc(self.next_doc(EsVecElt), f)
+            let doc = self.next_doc(EsVecElt);
+
+            let (old_parent, old_pos) = (self.parent, self.pos);
+            self.parent = doc;
+            self.pos = self.parent.start;
+
+            let result = f(self);
+
+            self.parent = old_parent;
+            self.pos = old_pos;
+            result
         }
 
-        fn read_map<T>(&self, _f: &fn(uint) -> T) -> T {
+        fn read_map<T>(&mut self, _: &fn(&mut Decoder, uint) -> T) -> T {
             debug!("read_map()");
             fail!(~"read_map is unimplemented");
         }
 
-        fn read_map_elt_key<T>(&self, idx: uint, _f: &fn() -> T) -> T {
+        fn read_map_elt_key<T>(&mut self,
+                               idx: uint,
+                               _: &fn(&mut Decoder) -> T)
+                               -> T {
             debug!("read_map_elt_key(idx=%u)", idx);
             fail!(~"read_map_elt_val is unimplemented");
         }
 
-        fn read_map_elt_val<T>(&self, idx: uint, _f: &fn() -> T) -> T {
+        fn read_map_elt_val<T>(&mut self,
+                               idx: uint,
+                               _: &fn(&mut Decoder) -> T)
+                               -> T {
             debug!("read_map_elt_val(idx=%u)", idx);
             fail!(~"read_map_elt_val is unimplemented");
         }
@@ -513,7 +631,7 @@ pub mod writer {
 
     // FIXME (#2741): Provide a function to write the standard ebml header.
     pub impl Encoder {
-        fn start_tag(&self, tag_id: uint) {
+        fn start_tag(&mut self, tag_id: uint) {
             debug!("Start tag %u", tag_id);
 
             // Write the enum ID:
@@ -525,7 +643,7 @@ pub mod writer {
             self.writer.write(zeroes);
         }
 
-        fn end_tag(&self) {
+        fn end_tag(&mut self) {
             let last_size_pos = self.size_positions.pop();
             let cur_pos = self.writer.tell();
             self.writer.seek(last_size_pos as int, io::SeekSet);
@@ -536,72 +654,72 @@ pub mod writer {
             debug!("End tag (size = %u)", size);
         }
 
-        fn wr_tag(&self, tag_id: uint, blk: &fn()) {
+        fn wr_tag(&mut self, tag_id: uint, blk: &fn()) {
             self.start_tag(tag_id);
             blk();
             self.end_tag();
         }
 
-        fn wr_tagged_bytes(&self, tag_id: uint, b: &[u8]) {
+        fn wr_tagged_bytes(&mut self, tag_id: uint, b: &[u8]) {
             write_vuint(self.writer, tag_id);
             write_vuint(self.writer, vec::len(b));
             self.writer.write(b);
         }
 
-        fn wr_tagged_u64(&self, tag_id: uint, v: u64) {
+        fn wr_tagged_u64(&mut self, tag_id: uint, v: u64) {
             do io::u64_to_be_bytes(v, 8u) |v| {
                 self.wr_tagged_bytes(tag_id, v);
             }
         }
 
-        fn wr_tagged_u32(&self, tag_id: uint, v: u32) {
+        fn wr_tagged_u32(&mut self, tag_id: uint, v: u32) {
             do io::u64_to_be_bytes(v as u64, 4u) |v| {
                 self.wr_tagged_bytes(tag_id, v);
             }
         }
 
-        fn wr_tagged_u16(&self, tag_id: uint, v: u16) {
+        fn wr_tagged_u16(&mut self, tag_id: uint, v: u16) {
             do io::u64_to_be_bytes(v as u64, 2u) |v| {
                 self.wr_tagged_bytes(tag_id, v);
             }
         }
 
-        fn wr_tagged_u8(&self, tag_id: uint, v: u8) {
+        fn wr_tagged_u8(&mut self, tag_id: uint, v: u8) {
             self.wr_tagged_bytes(tag_id, &[v]);
         }
 
-        fn wr_tagged_i64(&self, tag_id: uint, v: i64) {
+        fn wr_tagged_i64(&mut self, tag_id: uint, v: i64) {
             do io::u64_to_be_bytes(v as u64, 8u) |v| {
                 self.wr_tagged_bytes(tag_id, v);
             }
         }
 
-        fn wr_tagged_i32(&self, tag_id: uint, v: i32) {
+        fn wr_tagged_i32(&mut self, tag_id: uint, v: i32) {
             do io::u64_to_be_bytes(v as u64, 4u) |v| {
                 self.wr_tagged_bytes(tag_id, v);
             }
         }
 
-        fn wr_tagged_i16(&self, tag_id: uint, v: i16) {
+        fn wr_tagged_i16(&mut self, tag_id: uint, v: i16) {
             do io::u64_to_be_bytes(v as u64, 2u) |v| {
                 self.wr_tagged_bytes(tag_id, v);
             }
         }
 
-        fn wr_tagged_i8(&self, tag_id: uint, v: i8) {
+        fn wr_tagged_i8(&mut self, tag_id: uint, v: i8) {
             self.wr_tagged_bytes(tag_id, &[v as u8]);
         }
 
-        fn wr_tagged_str(&self, tag_id: uint, v: &str) {
+        fn wr_tagged_str(&mut self, tag_id: uint, v: &str) {
             str::byte_slice(v, |b| self.wr_tagged_bytes(tag_id, b));
         }
 
-        fn wr_bytes(&self, b: &[u8]) {
+        fn wr_bytes(&mut self, b: &[u8]) {
             debug!("Write %u bytes", vec::len(b));
             self.writer.write(b);
         }
 
-        fn wr_str(&self, s: &str) {
+        fn wr_str(&mut self, s: &str) {
             debug!("Write str: %?", s);
             self.writer.write(str::to_bytes(s));
         }
@@ -612,16 +730,16 @@ pub mod writer {
 
     // Set to true to generate more debugging in EBML code.
     // Totally lame approach.
-    static debug: bool = false;
+    static debug: bool = true;
 
     priv impl Encoder {
         // used internally to emit things like the vector length and so on
-        fn _emit_tagged_uint(&self, t: EbmlEncoderTag, v: uint) {
+        fn _emit_tagged_uint(&mut self, t: EbmlEncoderTag, v: uint) {
             assert!(v <= 0xFFFF_FFFF_u); // FIXME(#6130) assert warns on 32-bit
             self.wr_tagged_u32(t as uint, v as u32);
         }
 
-        fn _emit_label(&self, label: &str) {
+        fn _emit_label(&mut self, label: &str) {
             // There are various strings that we have access to, such as
             // the name of a record field, which do not actually appear in
             // the encoded EBML (normally).  This is just for
@@ -633,118 +751,169 @@ pub mod writer {
     }
 
     pub impl Encoder {
-        fn emit_opaque(&self, f: &fn()) {
-            do self.wr_tag(EsOpaque as uint) {
-                f()
-            }
+        fn emit_opaque(&mut self, f: &fn(&mut Encoder)) {
+            self.start_tag(EsOpaque as uint);
+            f(self);
+            self.end_tag();
         }
     }
 
     impl ::serialize::Encoder for Encoder {
-        fn emit_nil(&self) {}
+        fn emit_nil(&mut self) {}
 
-        fn emit_uint(&self, v: uint) {
+        fn emit_uint(&mut self, v: uint) {
             self.wr_tagged_u64(EsUint as uint, v as u64);
         }
-        fn emit_u64(&self, v: u64) { self.wr_tagged_u64(EsU64 as uint, v); }
-        fn emit_u32(&self, v: u32) { self.wr_tagged_u32(EsU32 as uint, v); }
-        fn emit_u16(&self, v: u16) { self.wr_tagged_u16(EsU16 as uint, v); }
-        fn emit_u8(&self, v: u8)   { self.wr_tagged_u8 (EsU8  as uint, v); }
+        fn emit_u64(&mut self, v: u64) {
+            self.wr_tagged_u64(EsU64 as uint, v);
+        }
+        fn emit_u32(&mut self, v: u32) {
+            self.wr_tagged_u32(EsU32 as uint, v);
+        }
+        fn emit_u16(&mut self, v: u16) {
+            self.wr_tagged_u16(EsU16 as uint, v);
+        }
+        fn emit_u8(&mut self, v: u8) {
+            self.wr_tagged_u8(EsU8 as uint, v);
+        }
 
-        fn emit_int(&self, v: int) {
+        fn emit_int(&mut self, v: int) {
             self.wr_tagged_i64(EsInt as uint, v as i64);
         }
-        fn emit_i64(&self, v: i64) { self.wr_tagged_i64(EsI64 as uint, v); }
-        fn emit_i32(&self, v: i32) { self.wr_tagged_i32(EsI32 as uint, v); }
-        fn emit_i16(&self, v: i16) { self.wr_tagged_i16(EsI16 as uint, v); }
-        fn emit_i8(&self, v: i8)   { self.wr_tagged_i8 (EsI8  as uint, v); }
+        fn emit_i64(&mut self, v: i64) {
+            self.wr_tagged_i64(EsI64 as uint, v);
+        }
+        fn emit_i32(&mut self, v: i32) {
+            self.wr_tagged_i32(EsI32 as uint, v);
+        }
+        fn emit_i16(&mut self, v: i16) {
+            self.wr_tagged_i16(EsI16 as uint, v);
+        }
+        fn emit_i8(&mut self, v: i8) {
+            self.wr_tagged_i8(EsI8 as uint, v);
+        }
 
-        fn emit_bool(&self, v: bool) {
+        fn emit_bool(&mut self, v: bool) {
             self.wr_tagged_u8(EsBool as uint, v as u8)
         }
 
         // FIXME (#2742): implement these
-        fn emit_f64(&self, _v: f64) {
+        fn emit_f64(&mut self, _v: f64) {
             fail!(~"Unimplemented: serializing an f64");
         }
-        fn emit_f32(&self, _v: f32) {
+        fn emit_f32(&mut self, _v: f32) {
             fail!(~"Unimplemented: serializing an f32");
         }
-        fn emit_float(&self, _v: float) {
+        fn emit_float(&mut self, _v: float) {
             fail!(~"Unimplemented: serializing a float");
         }
 
-        fn emit_char(&self, _v: char) {
+        fn emit_char(&mut self, _v: char) {
             fail!(~"Unimplemented: serializing a char");
         }
 
-        fn emit_str(&self, v: &str) {
+        fn emit_str(&mut self, v: &str) {
             self.wr_tagged_str(EsStr as uint, v)
         }
 
-        fn emit_enum(&self, name: &str, f: &fn()) {
+        fn emit_enum(&mut self, name: &str, f: &fn(&mut Encoder)) {
             self._emit_label(name);
-            self.wr_tag(EsEnum as uint, f)
+            self.start_tag(EsEnum as uint);
+            f(self);
+            self.end_tag();
         }
 
-        fn emit_enum_variant(&self, _v_name: &str, v_id: uint, _cnt: uint,
-                             f: &fn()) {
+        fn emit_enum_variant(&mut self,
+                             _: &str,
+                             v_id: uint,
+                             _: uint,
+                             f: &fn(&mut Encoder)) {
             self._emit_tagged_uint(EsEnumVid, v_id);
-            self.wr_tag(EsEnumBody as uint, f)
+            self.start_tag(EsEnumBody as uint);
+            f(self);
+            self.end_tag();
         }
 
-        fn emit_enum_variant_arg(&self, _idx: uint, f: &fn()) { f() }
+        fn emit_enum_variant_arg(&mut self, _: uint, f: &fn(&mut Encoder)) {
+            f(self)
+        }
 
-        fn emit_enum_struct_variant(&self, v_name: &str, v_id: uint, cnt: uint, f: &fn()) {
+        fn emit_enum_struct_variant(&mut self,
+                                    v_name: &str,
+                                    v_id: uint,
+                                    cnt: uint,
+                                    f: &fn(&mut Encoder)) {
             self.emit_enum_variant(v_name, v_id, cnt, f)
         }
 
-        fn emit_enum_struct_variant_field(&self, _f_name: &str, idx: uint, f: &fn()) {
+        fn emit_enum_struct_variant_field(&mut self,
+                                          _: &str,
+                                          idx: uint,
+                                          f: &fn(&mut Encoder)) {
             self.emit_enum_variant_arg(idx, f)
         }
 
-        fn emit_struct(&self, _name: &str, _len: uint, f: &fn()) { f() }
-        fn emit_struct_field(&self, name: &str, _idx: uint, f: &fn()) {
+        fn emit_struct(&mut self, _: &str, _len: uint, f: &fn(&mut Encoder)) {
+            f(self)
+        }
+
+        fn emit_struct_field(&mut self,
+                             name: &str,
+                             _: uint,
+                             f: &fn(&mut Encoder)) {
             self._emit_label(name);
-            f()
+            f(self)
         }
 
-        fn emit_tuple(&self, len: uint, f: &fn()) { self.emit_seq(len, f) }
-        fn emit_tuple_arg(&self, idx: uint, f: &fn()) { self.emit_seq_elt(idx, f) }
+        fn emit_tuple(&mut self, len: uint, f: &fn(&mut Encoder)) {
+            self.emit_seq(len, f)
+        }
+        fn emit_tuple_arg(&mut self, idx: uint, f: &fn(&mut Encoder)) {
+            self.emit_seq_elt(idx, f)
+        }
 
-        fn emit_tuple_struct(&self, _name: &str, len: uint, f: &fn()) { self.emit_seq(len, f) }
-        fn emit_tuple_struct_arg(&self, idx: uint, f: &fn()) { self.emit_seq_elt(idx, f) }
+        fn emit_tuple_struct(&mut self,
+                             _: &str,
+                             len: uint,
+                             f: &fn(&mut Encoder)) {
+            self.emit_seq(len, f)
+        }
+        fn emit_tuple_struct_arg(&mut self, idx: uint, f: &fn(&mut Encoder)) {
+            self.emit_seq_elt(idx, f)
+        }
 
-        fn emit_option(&self, f: &fn()) {
+        fn emit_option(&mut self, f: &fn(&mut Encoder)) {
             self.emit_enum("Option", f);
         }
-        fn emit_option_none(&self) {
-            self.emit_enum_variant("None", 0, 0, || ())
+        fn emit_option_none(&mut self) {
+            self.emit_enum_variant("None", 0, 0, |_| ())
         }
-        fn emit_option_some(&self, f: &fn()) {
+        fn emit_option_some(&mut self, f: &fn(&mut Encoder)) {
             self.emit_enum_variant("Some", 1, 1, f)
         }
 
-        fn emit_seq(&self, len: uint, f: &fn()) {
-            do self.wr_tag(EsVec as uint) {
-                self._emit_tagged_uint(EsVecLen, len);
-                f()
-            }
+        fn emit_seq(&mut self, len: uint, f: &fn(&mut Encoder)) {
+            self.start_tag(EsVec as uint);
+            self._emit_tagged_uint(EsVecLen, len);
+            f(self);
+            self.end_tag();
         }
 
-        fn emit_seq_elt(&self, _idx: uint, f: &fn()) {
-            self.wr_tag(EsVecElt as uint, f)
+        fn emit_seq_elt(&mut self, _idx: uint, f: &fn(&mut Encoder)) {
+            self.start_tag(EsVecElt as uint);
+            f(self);
+            self.end_tag();
         }
 
-        fn emit_map(&self, _len: uint, _f: &fn()) {
+        fn emit_map(&mut self, _len: uint, _f: &fn(&mut Encoder)) {
             fail!(~"emit_map is unimplemented");
         }
 
-        fn emit_map_elt_key(&self, _idx: uint, _f: &fn()) {
+        fn emit_map_elt_key(&mut self, _idx: uint, _f: &fn(&mut Encoder)) {
             fail!(~"emit_map_elt_key is unimplemented");
         }
 
-        fn emit_map_elt_val(&self, _idx: uint, _f: &fn()) {
+        fn emit_map_elt_val(&mut self, _idx: uint, _f: &fn(&mut Encoder)) {
             fail!(~"emit_map_elt_val is unimplemented");
         }
     }
@@ -768,12 +937,12 @@ mod tests {
         fn test_v(v: Option<int>) {
             debug!("v == %?", v);
             let bytes = do io::with_bytes_writer |wr| {
-                let ebml_w = writer::Encoder(wr);
-                v.encode(&ebml_w)
+                let mut ebml_w = writer::Encoder(wr);
+                v.encode(&mut ebml_w)
             };
             let ebml_doc = reader::Doc(@bytes);
-            let deser = reader::Decoder(ebml_doc);
-            let v1 = serialize::Decodable::decode(&deser);
+            let mut deser = reader::Decoder(ebml_doc);
+            let v1 = serialize::Decodable::decode(&mut deser);
             debug!("v1 == %?", v1);
             assert!(v == v1);
         }
diff --git a/src/libstd/flatpipes.rs b/src/libstd/flatpipes.rs
index bd0acb849fc..88de53f3605 100644
--- a/src/libstd/flatpipes.rs
+++ b/src/libstd/flatpipes.rs
@@ -439,19 +439,23 @@ pub mod flatteners {
     */
 
     pub fn deserialize_buffer<D: Decoder + FromReader,
-                              T: Decodable<D>>(buf: &[u8]) -> T {
+                              T: Decodable<D>>(
+                              buf: &[u8])
+                              -> T {
         let buf = vec::from_slice(buf);
         let buf_reader = @BufReader::new(buf);
         let reader = buf_reader as @Reader;
-        let deser: D = FromReader::from_reader(reader);
-        Decodable::decode(&deser)
+        let mut deser: D = FromReader::from_reader(reader);
+        Decodable::decode(&mut deser)
     }
 
     pub fn serialize_value<D: Encoder + FromWriter,
-                           T: Encodable<D>>(val: &T) -> ~[u8] {
+                           T: Encodable<D>>(
+                           val: &T)
+                           -> ~[u8] {
         do io::with_bytes_writer |writer| {
-            let ser = FromWriter::from_writer(writer);
-            val.encode(&ser);
+            let mut ser = FromWriter::from_writer(writer);
+            val.encode(&mut ser);
         }
     }
 
@@ -649,6 +653,7 @@ mod test {
     }
 
     #[test]
+    #[ignore(reason = "FIXME #6211 failing on linux snapshot machine")]
     fn test_serializing_pipes() {
         let (port, chan) = serial::pipe_stream();
 
diff --git a/src/libstd/getopts.rs b/src/libstd/getopts.rs
index fda5c105da5..c03042fe9c2 100644
--- a/src/libstd/getopts.rs
+++ b/src/libstd/getopts.rs
@@ -1374,11 +1374,3 @@ Options:
         assert!(usage == expected)
     }
 }
-
-// Local Variables:
-// mode: rust;
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
diff --git a/src/libstd/json.rs b/src/libstd/json.rs
index 5d5b0bd952f..3960a07dfce 100644
--- a/src/libstd/json.rs
+++ b/src/libstd/json.rs
@@ -72,25 +72,27 @@ pub struct Encoder {
 }
 
 pub fn Encoder(wr: @io::Writer) -> Encoder {
-    Encoder { wr: wr }
+    Encoder {
+        wr: wr
+    }
 }
 
 impl serialize::Encoder for Encoder {
-    fn emit_nil(&self) { self.wr.write_str("null") }
+    fn emit_nil(&mut self) { self.wr.write_str("null") }
 
-    fn emit_uint(&self, v: uint) { self.emit_float(v as float); }
-    fn emit_u64(&self, v: u64) { self.emit_float(v as float); }
-    fn emit_u32(&self, v: u32) { self.emit_float(v as float); }
-    fn emit_u16(&self, v: u16) { self.emit_float(v as float); }
-    fn emit_u8(&self, v: u8)   { self.emit_float(v as float); }
+    fn emit_uint(&mut self, v: uint) { self.emit_float(v as float); }
+    fn emit_u64(&mut self, v: u64) { self.emit_float(v as float); }
+    fn emit_u32(&mut self, v: u32) { self.emit_float(v as float); }
+    fn emit_u16(&mut self, v: u16) { self.emit_float(v as float); }
+    fn emit_u8(&mut self, v: u8)   { self.emit_float(v as float); }
 
-    fn emit_int(&self, v: int) { self.emit_float(v as float); }
-    fn emit_i64(&self, v: i64) { self.emit_float(v as float); }
-    fn emit_i32(&self, v: i32) { self.emit_float(v as float); }
-    fn emit_i16(&self, v: i16) { self.emit_float(v as float); }
-    fn emit_i8(&self, v: i8)   { self.emit_float(v as float); }
+    fn emit_int(&mut self, v: int) { self.emit_float(v as float); }
+    fn emit_i64(&mut self, v: i64) { self.emit_float(v as float); }
+    fn emit_i32(&mut self, v: i32) { self.emit_float(v as float); }
+    fn emit_i16(&mut self, v: i16) { self.emit_float(v as float); }
+    fn emit_i8(&mut self, v: i8)   { self.emit_float(v as float); }
 
-    fn emit_bool(&self, v: bool) {
+    fn emit_bool(&mut self, v: bool) {
         if v {
             self.wr.write_str("true");
         } else {
@@ -98,18 +100,22 @@ impl serialize::Encoder for Encoder {
         }
     }
 
-    fn emit_f64(&self, v: f64) { self.emit_float(v as float); }
-    fn emit_f32(&self, v: f32) { self.emit_float(v as float); }
-    fn emit_float(&self, v: float) {
+    fn emit_f64(&mut self, v: f64) { self.emit_float(v as float); }
+    fn emit_f32(&mut self, v: f32) { self.emit_float(v as float); }
+    fn emit_float(&mut self, v: float) {
         self.wr.write_str(float::to_str_digits(v, 6u));
     }
 
-    fn emit_char(&self, v: char) { self.emit_str(str::from_char(v)) }
-    fn emit_str(&self, v: &str) { self.wr.write_str(escape_str(v)) }
+    fn emit_char(&mut self, v: char) { self.emit_str(str::from_char(v)) }
+    fn emit_str(&mut self, v: &str) { self.wr.write_str(escape_str(v)) }
 
-    fn emit_enum(&self, _name: &str, f: &fn()) { f() }
+    fn emit_enum(&mut self, _name: &str, f: &fn(&mut Encoder)) { f(self) }
 
-    fn emit_enum_variant(&self, name: &str, _id: uint, cnt: uint, f: &fn()) {
+    fn emit_enum_variant(&mut self,
+                         name: &str,
+                         _id: uint,
+                         cnt: uint,
+                         f: &fn(&mut Encoder)) {
         // enums are encoded as strings or vectors:
         // Bunny => "Bunny"
         // Kangaroo(34,"William") => ["Kangaroo",[34,"William"]]
@@ -120,71 +126,97 @@ impl serialize::Encoder for Encoder {
             self.wr.write_char('[');
             self.wr.write_str(escape_str(name));
             self.wr.write_char(',');
-            f();
+            f(self);
             self.wr.write_char(']');
         }
     }
 
-    fn emit_enum_variant_arg(&self, idx: uint, f: &fn()) {
-        if idx != 0 {self.wr.write_char(',');}
-        f();
+    fn emit_enum_variant_arg(&mut self, idx: uint, f: &fn(&mut Encoder)) {
+        if idx != 0 {
+            self.wr.write_char(',');
+        }
+        f(self);
     }
 
-    fn emit_enum_struct_variant(&self, name: &str, id: uint, cnt: uint, f: &fn()) {
+    fn emit_enum_struct_variant(&mut self,
+                                name: &str,
+                                id: uint,
+                                cnt: uint,
+                                f: &fn(&mut Encoder)) {
         self.emit_enum_variant(name, id, cnt, f)
     }
 
-    fn emit_enum_struct_variant_field(&self, _field: &str, idx: uint, f: &fn()) {
+    fn emit_enum_struct_variant_field(&mut self,
+                                      _: &str,
+                                      idx: uint,
+                                      f: &fn(&mut Encoder)) {
         self.emit_enum_variant_arg(idx, f)
     }
 
-    fn emit_struct(&self, _name: &str, _len: uint, f: &fn()) {
+    fn emit_struct(&mut self, _: &str, _: uint, f: &fn(&mut Encoder)) {
         self.wr.write_char('{');
-        f();
+        f(self);
         self.wr.write_char('}');
     }
-    fn emit_struct_field(&self, name: &str, idx: uint, f: &fn()) {
+
+    fn emit_struct_field(&mut self,
+                         name: &str,
+                         idx: uint,
+                         f: &fn(&mut Encoder)) {
         if idx != 0 { self.wr.write_char(','); }
         self.wr.write_str(escape_str(name));
         self.wr.write_char(':');
-        f();
+        f(self);
     }
 
-    fn emit_tuple(&self, len: uint, f: &fn()) { self.emit_seq(len, f) }
-    fn emit_tuple_arg(&self, idx: uint, f: &fn()) { self.emit_seq_elt(idx, f) }
+    fn emit_tuple(&mut self, len: uint, f: &fn(&mut Encoder)) {
+        self.emit_seq(len, f)
+    }
+    fn emit_tuple_arg(&mut self, idx: uint, f: &fn(&mut Encoder)) {
+        self.emit_seq_elt(idx, f)
+    }
 
-    fn emit_tuple_struct(&self, _name: &str, len: uint, f: &fn()) { self.emit_seq(len, f) }
-    fn emit_tuple_struct_arg(&self, idx: uint, f: &fn()) { self.emit_seq_elt(idx, f) }
+    fn emit_tuple_struct(&mut self,
+                         _name: &str,
+                         len: uint,
+                         f: &fn(&mut Encoder)) {
+        self.emit_seq(len, f)
+    }
+    fn emit_tuple_struct_arg(&mut self, idx: uint, f: &fn(&mut Encoder)) {
+        self.emit_seq_elt(idx, f)
+    }
 
-    fn emit_option(&self, f: &fn()) { f(); }
-    fn emit_option_none(&self) { self.emit_nil(); }
-    fn emit_option_some(&self, f: &fn()) { f(); }
+    fn emit_option(&mut self, f: &fn(&mut Encoder)) { f(self); }
+    fn emit_option_none(&mut self) { self.emit_nil(); }
+    fn emit_option_some(&mut self, f: &fn(&mut Encoder)) { f(self); }
 
-    fn emit_seq(&self, _len: uint, f: &fn()) {
+    fn emit_seq(&mut self, _len: uint, f: &fn(&mut Encoder)) {
         self.wr.write_char('[');
-        f();
+        f(self);
         self.wr.write_char(']');
     }
 
-    fn emit_seq_elt(&self, idx: uint, f: &fn()) {
-        if idx != 0 { self.wr.write_char(','); }
-        f()
+    fn emit_seq_elt(&mut self, idx: uint, f: &fn(&mut Encoder)) {
+        if idx != 0 {
+            self.wr.write_char(',');
+        }
+        f(self)
     }
 
-    fn emit_map(&self, _len: uint, f: &fn()) {
+    fn emit_map(&mut self, _len: uint, f: &fn(&mut Encoder)) {
         self.wr.write_char('{');
-        f();
+        f(self);
         self.wr.write_char('}');
     }
 
-    fn emit_map_elt_key(&self, idx: uint, f: &fn()) {
+    fn emit_map_elt_key(&mut self, idx: uint, f: &fn(&mut Encoder)) {
         if idx != 0 { self.wr.write_char(','); }
-        f()
+        f(self)
     }
 
-    fn emit_map_elt_val(&self, _idx: uint, f: &fn()) {
+    fn emit_map_elt_val(&mut self, _idx: uint, f: &fn(&mut Encoder)) {
         self.wr.write_char(':');
-        f()
+        f(self)
     }
 }
 
@@ -194,25 +226,28 @@ pub struct PrettyEncoder {
 }
 
 pub fn PrettyEncoder(wr: @io::Writer) -> PrettyEncoder {
-    PrettyEncoder { wr: wr, indent: 0 }
+    PrettyEncoder {
+        wr: wr,
+        indent: 0,
+    }
 }
 
 impl serialize::Encoder for PrettyEncoder {
-    fn emit_nil(&self) { self.wr.write_str("null") }
+    fn emit_nil(&mut self) { self.wr.write_str("null") }
 
-    fn emit_uint(&self, v: uint) { self.emit_float(v as float); }
-    fn emit_u64(&self, v: u64) { self.emit_float(v as float); }
-    fn emit_u32(&self, v: u32) { self.emit_float(v as float); }
-    fn emit_u16(&self, v: u16) { self.emit_float(v as float); }
-    fn emit_u8(&self, v: u8)   { self.emit_float(v as float); }
+    fn emit_uint(&mut self, v: uint) { self.emit_float(v as float); }
+    fn emit_u64(&mut self, v: u64) { self.emit_float(v as float); }
+    fn emit_u32(&mut self, v: u32) { self.emit_float(v as float); }
+    fn emit_u16(&mut self, v: u16) { self.emit_float(v as float); }
+    fn emit_u8(&mut self, v: u8)   { self.emit_float(v as float); }
 
-    fn emit_int(&self, v: int) { self.emit_float(v as float); }
-    fn emit_i64(&self, v: i64) { self.emit_float(v as float); }
-    fn emit_i32(&self, v: i32) { self.emit_float(v as float); }
-    fn emit_i16(&self, v: i16) { self.emit_float(v as float); }
-    fn emit_i8(&self, v: i8)   { self.emit_float(v as float); }
+    fn emit_int(&mut self, v: int) { self.emit_float(v as float); }
+    fn emit_i64(&mut self, v: i64) { self.emit_float(v as float); }
+    fn emit_i32(&mut self, v: i32) { self.emit_float(v as float); }
+    fn emit_i16(&mut self, v: i16) { self.emit_float(v as float); }
+    fn emit_i8(&mut self, v: i8)   { self.emit_float(v as float); }
 
-    fn emit_bool(&self, v: bool) {
+    fn emit_bool(&mut self, v: bool) {
         if v {
             self.wr.write_str("true");
         } else {
@@ -220,18 +255,24 @@ impl serialize::Encoder for PrettyEncoder {
         }
     }
 
-    fn emit_f64(&self, v: f64) { self.emit_float(v as float); }
-    fn emit_f32(&self, v: f32) { self.emit_float(v as float); }
-    fn emit_float(&self, v: float) {
+    fn emit_f64(&mut self, v: f64) { self.emit_float(v as float); }
+    fn emit_f32(&mut self, v: f32) { self.emit_float(v as float); }
+    fn emit_float(&mut self, v: float) {
         self.wr.write_str(float::to_str_digits(v, 6u));
     }
 
-    fn emit_char(&self, v: char) { self.emit_str(str::from_char(v)) }
-    fn emit_str(&self, v: &str) { self.wr.write_str(escape_str(v)); }
+    fn emit_char(&mut self, v: char) { self.emit_str(str::from_char(v)) }
+    fn emit_str(&mut self, v: &str) { self.wr.write_str(escape_str(v)); }
 
-    fn emit_enum(&self, _name: &str, f: &fn()) { f() }
+    fn emit_enum(&mut self, _name: &str, f: &fn(&mut PrettyEncoder)) {
+        f(self)
+    }
 
-    fn emit_enum_variant(&self, name: &str, _id: uint, cnt: uint, f: &fn()) {
+    fn emit_enum_variant(&mut self,
+                         name: &str,
+                         _: uint,
+                         cnt: uint,
+                         f: &fn(&mut PrettyEncoder)) {
         if cnt == 0 {
             self.wr.write_str(escape_str(name));
         } else {
@@ -241,7 +282,7 @@ impl serialize::Encoder for PrettyEncoder {
             self.wr.write_str(spaces(self.indent));
             self.wr.write_str(escape_str(name));
             self.wr.write_str(",\n");
-            f();
+            f(self);
             self.wr.write_char('\n');
             self.indent -= 2;
             self.wr.write_str(spaces(self.indent));
@@ -249,37 +290,53 @@ impl serialize::Encoder for PrettyEncoder {
         }
     }
 
-    fn emit_enum_variant_arg(&self, idx: uint, f: &fn()) {
+    fn emit_enum_variant_arg(&mut self,
+                             idx: uint,
+                             f: &fn(&mut PrettyEncoder)) {
         if idx != 0 {
             self.wr.write_str(",\n");
         }
         self.wr.write_str(spaces(self.indent));
-        f()
+        f(self)
     }
 
-    fn emit_enum_struct_variant(&self, name: &str, id: uint, cnt: uint, f: &fn()) {
+    fn emit_enum_struct_variant(&mut self,
+                                name: &str,
+                                id: uint,
+                                cnt: uint,
+                                f: &fn(&mut PrettyEncoder)) {
         self.emit_enum_variant(name, id, cnt, f)
     }
 
-    fn emit_enum_struct_variant_field(&self, _field: &str, idx: uint, f: &fn()) {
+    fn emit_enum_struct_variant_field(&mut self,
+                                      _: &str,
+                                      idx: uint,
+                                      f: &fn(&mut PrettyEncoder)) {
         self.emit_enum_variant_arg(idx, f)
     }
 
 
-    fn emit_struct(&self, _name: &str, len: uint, f: &fn()) {
+    fn emit_struct(&mut self,
+                   _: &str,
+                   len: uint,
+                   f: &fn(&mut PrettyEncoder)) {
         if len == 0 {
             self.wr.write_str("{}");
         } else {
             self.wr.write_char('{');
             self.indent += 2;
-            f();
+            f(self);
             self.wr.write_char('\n');
             self.indent -= 2;
             self.wr.write_str(spaces(self.indent));
             self.wr.write_char('}');
         }
     }
-    fn emit_struct_field(&self, name: &str, idx: uint, f: &fn()) {
+
+    fn emit_struct_field(&mut self,
+                         name: &str,
+                         idx: uint,
+                         f: &fn(&mut PrettyEncoder)) {
         if idx == 0 {
             self.wr.write_char('\n');
         } else {
@@ -288,73 +345,88 @@ impl serialize::Encoder for PrettyEncoder {
         self.wr.write_str(spaces(self.indent));
         self.wr.write_str(escape_str(name));
         self.wr.write_str(": ");
-        f();
+        f(self);
     }
 
-    fn emit_tuple(&self, len: uint, f: &fn()) { self.emit_seq(len, f) }
-    fn emit_tuple_arg(&self, idx: uint, f: &fn()) { self.emit_seq_elt(idx, f) }
+    fn emit_tuple(&mut self, len: uint, f: &fn(&mut PrettyEncoder)) {
+        self.emit_seq(len, f)
+    }
+    fn emit_tuple_arg(&mut self, idx: uint, f: &fn(&mut PrettyEncoder)) {
+        self.emit_seq_elt(idx, f)
+    }
 
-    fn emit_tuple_struct(&self, _name: &str, len: uint, f: &fn()) { self.emit_seq(len, f) }
-    fn emit_tuple_struct_arg(&self, idx: uint, f: &fn()) { self.emit_seq_elt(idx, f) }
+    fn emit_tuple_struct(&mut self,
+                         _: &str,
+                         len: uint,
+                         f: &fn(&mut PrettyEncoder)) {
+        self.emit_seq(len, f)
+    }
+    fn emit_tuple_struct_arg(&mut self,
+                             idx: uint,
+                             f: &fn(&mut PrettyEncoder)) {
+        self.emit_seq_elt(idx, f)
+    }
 
-    fn emit_option(&self, f: &fn()) { f(); }
-    fn emit_option_none(&self) { self.emit_nil(); }
-    fn emit_option_some(&self, f: &fn()) { f(); }
+    fn emit_option(&mut self, f: &fn(&mut PrettyEncoder)) { f(self); }
+    fn emit_option_none(&mut self) { self.emit_nil(); }
+    fn emit_option_some(&mut self, f: &fn(&mut PrettyEncoder)) { f(self); }
 
-    fn emit_seq(&self, len: uint, f: &fn()) {
+    fn emit_seq(&mut self, len: uint, f: &fn(&mut PrettyEncoder)) {
         if len == 0 {
             self.wr.write_str("[]");
         } else {
             self.wr.write_char('[');
             self.indent += 2;
-            f();
+            f(self);
             self.wr.write_char('\n');
             self.indent -= 2;
             self.wr.write_str(spaces(self.indent));
             self.wr.write_char(']');
         }
     }
-    fn emit_seq_elt(&self, idx: uint, f: &fn()) {
+
+    fn emit_seq_elt(&mut self, idx: uint, f: &fn(&mut PrettyEncoder)) {
         if idx == 0 {
             self.wr.write_char('\n');
         } else {
             self.wr.write_str(",\n");
         }
         self.wr.write_str(spaces(self.indent));
-        f()
+        f(self)
     }
 
-    fn emit_map(&self, len: uint, f: &fn()) {
+    fn emit_map(&mut self, len: uint, f: &fn(&mut PrettyEncoder)) {
         if len == 0 {
             self.wr.write_str("{}");
         } else {
             self.wr.write_char('{');
             self.indent += 2;
-            f();
+            f(self);
             self.wr.write_char('\n');
             self.indent -= 2;
             self.wr.write_str(spaces(self.indent));
             self.wr.write_char('}');
         }
     }
-    fn emit_map_elt_key(&self, idx: uint, f: &fn()) {
+
+    fn emit_map_elt_key(&mut self, idx: uint, f: &fn(&mut PrettyEncoder)) {
         if idx == 0 {
             self.wr.write_char('\n');
         } else {
             self.wr.write_str(",\n");
         }
         self.wr.write_str(spaces(self.indent));
-        f();
+        f(self);
     }
 
-    fn emit_map_elt_val(&self, _idx: uint, f: &fn()) {
+    fn emit_map_elt_val(&mut self, _idx: uint, f: &fn(&mut PrettyEncoder)) {
         self.wr.write_str(": ");
-        f();
+        f(self);
     }
 }
 
 impl<E: serialize::Encoder> serialize::Encodable<E> for Json {
-    fn encode(&self, e: &E) {
+    fn encode(&self, e: &mut E) {
         match *self {
             Number(v) => v.encode(e),
             String(ref v) => v.encode(e),
@@ -368,7 +440,8 @@ impl<E: serialize::Encoder> serialize::Encodable<E> for Json {
 
 /// Encodes a json value into a io::writer
 pub fn to_writer(wr: @io::Writer, json: &Json) {
-    json.encode(&Encoder(wr))
+    let mut encoder = Encoder(wr);
+    json.encode(&mut encoder)
 }
 
 /// Encodes a json value into a string
@@ -378,7 +451,8 @@ pub fn to_str(json: &Json) -> ~str {
 
 /// Encodes a json value into a io::writer
 pub fn to_pretty_writer(wr: @io::Writer, json: &Json) {
-    json.encode(&PrettyEncoder(wr))
+    let mut encoder = PrettyEncoder(wr);
+    json.encode(&mut encoder)
 }
 
 /// Encodes a json value into a string
@@ -769,11 +843,13 @@ pub struct Decoder {
 }
 
 pub fn Decoder(json: Json) -> Decoder {
-    Decoder { stack: ~[json] }
+    Decoder {
+        stack: ~[json]
+    }
 }
 
 impl serialize::Decoder for Decoder {
-    fn read_nil(&self) -> () {
+    fn read_nil(&mut self) -> () {
         debug!("read_nil");
         match self.stack.pop() {
             Null => (),
@@ -781,19 +857,19 @@ impl serialize::Decoder for Decoder {
         }
     }
 
-    fn read_u64(&self)  -> u64  { self.read_float() as u64 }
-    fn read_u32(&self)  -> u32  { self.read_float() as u32 }
-    fn read_u16(&self)  -> u16  { self.read_float() as u16 }
-    fn read_u8 (&self)  -> u8   { self.read_float() as u8 }
-    fn read_uint(&self) -> uint { self.read_float() as uint }
+    fn read_u64(&mut self)  -> u64  { self.read_float() as u64 }
+    fn read_u32(&mut self)  -> u32  { self.read_float() as u32 }
+    fn read_u16(&mut self)  -> u16  { self.read_float() as u16 }
+    fn read_u8 (&mut self)  -> u8   { self.read_float() as u8 }
+    fn read_uint(&mut self) -> uint { self.read_float() as uint }
 
-    fn read_i64(&self) -> i64 { self.read_float() as i64 }
-    fn read_i32(&self) -> i32 { self.read_float() as i32 }
-    fn read_i16(&self) -> i16 { self.read_float() as i16 }
-    fn read_i8 (&self) -> i8  { self.read_float() as i8 }
-    fn read_int(&self) -> int { self.read_float() as int }
+    fn read_i64(&mut self) -> i64 { self.read_float() as i64 }
+    fn read_i32(&mut self) -> i32 { self.read_float() as i32 }
+    fn read_i16(&mut self) -> i16 { self.read_float() as i16 }
+    fn read_i8 (&mut self) -> i8  { self.read_float() as i8 }
+    fn read_int(&mut self) -> int { self.read_float() as int }
 
-    fn read_bool(&self) -> bool {
+    fn read_bool(&mut self) -> bool {
         debug!("read_bool");
         match self.stack.pop() {
             Boolean(b) => b,
@@ -801,9 +877,9 @@ impl serialize::Decoder for Decoder {
         }
     }
 
-    fn read_f64(&self) -> f64 { self.read_float() as f64 }
-    fn read_f32(&self) -> f32 { self.read_float() as f32 }
-    fn read_float(&self) -> float {
+    fn read_f64(&mut self) -> f64 { self.read_float() as f64 }
+    fn read_f32(&mut self) -> f32 { self.read_float() as f32 }
+    fn read_float(&mut self) -> float {
         debug!("read_float");
         match self.stack.pop() {
             Number(f) => f,
@@ -811,14 +887,14 @@ impl serialize::Decoder for Decoder {
         }
     }
 
-    fn read_char(&self) -> char {
+    fn read_char(&mut self) -> char {
         let mut v = ~[];
         for str::each_char(self.read_str()) |c| { v.push(c) }
         if v.len() != 1 { fail!(~"string must have one character") }
         v[0]
     }
 
-    fn read_str(&self) -> ~str {
+    fn read_str(&mut self) -> ~str {
         debug!("read_str");
         match self.stack.pop() {
             String(s) => s,
@@ -826,12 +902,15 @@ impl serialize::Decoder for Decoder {
         }
     }
 
-    fn read_enum<T>(&self, name: &str, f: &fn() -> T) -> T {
+    fn read_enum<T>(&mut self, name: &str, f: &fn(&mut Decoder) -> T) -> T {
         debug!("read_enum(%s)", name);
-        f()
+        f(self)
     }
 
-    fn read_enum_variant<T>(&self, names: &[&str], f: &fn(uint) -> T) -> T {
+    fn read_enum_variant<T>(&mut self,
+                            names: &[&str],
+                            f: &fn(&mut Decoder, uint) -> T)
+                            -> T {
         debug!("read_enum_variant(names=%?)", names);
         let name = match self.stack.pop() {
             String(s) => s,
@@ -850,33 +929,51 @@ impl serialize::Decoder for Decoder {
             Some(idx) => idx,
             None => fail!(fmt!("Unknown variant name: %?", name)),
         };
-        f(idx)
+        f(self, idx)
     }
 
-    fn read_enum_variant_arg<T>(&self, idx: uint, f: &fn() -> T) -> T {
+    fn read_enum_variant_arg<T>(&mut self,
+                                idx: uint,
+                                f: &fn(&mut Decoder) -> T)
+                                -> T {
         debug!("read_enum_variant_arg(idx=%u)", idx);
-        f()
+        f(self)
     }
 
-    fn read_enum_struct_variant<T>(&self, names: &[&str], f: &fn(uint) -> T) -> T {
+    fn read_enum_struct_variant<T>(&mut self,
+                                   names: &[&str],
+                                   f: &fn(&mut Decoder, uint) -> T)
+                                   -> T {
         debug!("read_enum_struct_variant(names=%?)", names);
         self.read_enum_variant(names, f)
     }
 
 
-    fn read_enum_struct_variant_field<T>(&self, name: &str, idx: uint, f: &fn() -> T) -> T {
+    fn read_enum_struct_variant_field<T>(&mut self,
+                                         name: &str,
+                                         idx: uint,
+                                         f: &fn(&mut Decoder) -> T)
+                                         -> T {
         debug!("read_enum_struct_variant_field(name=%?, idx=%u)", name, idx);
         self.read_enum_variant_arg(idx, f)
     }
 
-    fn read_struct<T>(&self, name: &str, len: uint, f: &fn() -> T) -> T {
+    fn read_struct<T>(&mut self,
+                      name: &str,
+                      len: uint,
+                      f: &fn(&mut Decoder) -> T)
+                      -> T {
         debug!("read_struct(name=%s, len=%u)", name, len);
-        let value = f();
+        let value = f(self);
         self.stack.pop();
         value
     }
 
-    fn read_struct_field<T>(&self, name: &str, idx: uint, f: &fn() -> T) -> T {
+    fn read_struct_field<T>(&mut self,
+                            name: &str,
+                            idx: uint,
+                            f: &fn(&mut Decoder) -> T)
+                            -> T {
         debug!("read_struct_field(name=%?, idx=%u)", name, idx);
         match self.stack.pop() {
             Object(obj) => {
@@ -885,7 +982,7 @@ impl serialize::Decoder for Decoder {
                     None => fail!(fmt!("no such field: %s", name)),
                     Some(json) => {
                         self.stack.push(json);
-                        f()
+                        f(self)
                     }
                 };
                 self.stack.push(Object(obj));
@@ -895,34 +992,43 @@ impl serialize::Decoder for Decoder {
         }
     }
 
-    fn read_tuple<T>(&self, f: &fn(uint) -> T) -> T {
+    fn read_tuple<T>(&mut self, f: &fn(&mut Decoder, uint) -> T) -> T {
         debug!("read_tuple()");
         self.read_seq(f)
     }
 
-    fn read_tuple_arg<T>(&self, idx: uint, f: &fn() -> T) -> T {
+    fn read_tuple_arg<T>(&mut self,
+                         idx: uint,
+                         f: &fn(&mut Decoder) -> T)
+                         -> T {
         debug!("read_tuple_arg(idx=%u)", idx);
         self.read_seq_elt(idx, f)
     }
 
-    fn read_tuple_struct<T>(&self, name: &str, f: &fn(uint) -> T) -> T {
+    fn read_tuple_struct<T>(&mut self,
+                            name: &str,
+                            f: &fn(&mut Decoder, uint) -> T)
+                            -> T {
         debug!("read_tuple_struct(name=%?)", name);
         self.read_tuple(f)
     }
 
-    fn read_tuple_struct_arg<T>(&self, idx: uint, f: &fn() -> T) -> T {
+    fn read_tuple_struct_arg<T>(&mut self,
+                                idx: uint,
+                                f: &fn(&mut Decoder) -> T)
+                                -> T {
         debug!("read_tuple_struct_arg(idx=%u)", idx);
         self.read_tuple_arg(idx, f)
     }
 
-    fn read_option<T>(&self, f: &fn(bool) -> T) -> T {
+    fn read_option<T>(&mut self, f: &fn(&mut Decoder, bool) -> T) -> T {
         match self.stack.pop() {
-            Null => f(false),
-            value => { self.stack.push(value); f(true) }
+            Null => f(self, false),
+            value => { self.stack.push(value); f(self, true) }
         }
     }
 
-    fn read_seq<T>(&self, f: &fn(uint) -> T) -> T {
+    fn read_seq<T>(&mut self, f: &fn(&mut Decoder, uint) -> T) -> T {
         debug!("read_seq()");
         let len = match self.stack.pop() {
             List(list) => {
@@ -934,15 +1040,15 @@ impl serialize::Decoder for Decoder {
             }
             _ => fail!(~"not a list"),
         };
-        f(len)
+        f(self, len)
     }
 
-    fn read_seq_elt<T>(&self, idx: uint, f: &fn() -> T) -> T {
+    fn read_seq_elt<T>(&mut self, idx: uint, f: &fn(&mut Decoder) -> T) -> T {
         debug!("read_seq_elt(idx=%u)", idx);
-        f()
+        f(self)
     }
 
-    fn read_map<T>(&self, f: &fn(uint) -> T) -> T {
+    fn read_map<T>(&mut self, f: &fn(&mut Decoder, uint) -> T) -> T {
         debug!("read_map()");
         let len = match self.stack.pop() {
             Object(obj) => {
@@ -956,17 +1062,21 @@ impl serialize::Decoder for Decoder {
             }
             json => fail!(fmt!("not an object: %?", json)),
         };
-        f(len)
+        f(self, len)
     }
 
-    fn read_map_elt_key<T>(&self, idx: uint, f: &fn() -> T) -> T {
+    fn read_map_elt_key<T>(&mut self,
+                           idx: uint,
+                           f: &fn(&mut Decoder) -> T)
+                           -> T {
         debug!("read_map_elt_key(idx=%u)", idx);
-        f()
+        f(self)
     }
 
-    fn read_map_elt_val<T>(&self, idx: uint, f: &fn() -> T) -> T {
+    fn read_map_elt_val<T>(&mut self, idx: uint, f: &fn(&mut Decoder) -> T)
+                           -> T {
         debug!("read_map_elt_val(idx=%u)", idx);
-        f()
+        f(self)
     }
 }
 
@@ -1404,15 +1514,15 @@ mod tests {
         let animal = Dog;
         assert_eq!(
             do io::with_str_writer |wr| {
-                let encoder = Encoder(wr);
-                animal.encode(&encoder);
+                let mut encoder = Encoder(wr);
+                animal.encode(&mut encoder);
             },
             ~"\"Dog\""
         );
         assert_eq!(
             do io::with_str_writer |wr| {
-                let encoder = PrettyEncoder(wr);
-                animal.encode(&encoder);
+                let mut encoder = PrettyEncoder(wr);
+                animal.encode(&mut encoder);
             },
             ~"\"Dog\""
         );
@@ -1420,15 +1530,15 @@ mod tests {
         let animal = Frog(~"Henry", 349);
         assert_eq!(
             do io::with_str_writer |wr| {
-                let encoder = Encoder(wr);
-                animal.encode(&encoder);
+                let mut encoder = Encoder(wr);
+                animal.encode(&mut encoder);
             },
             ~"[\"Frog\",\"Henry\",349]"
         );
         assert_eq!(
             do io::with_str_writer |wr| {
-                let encoder = PrettyEncoder(wr);
-                animal.encode(&encoder);
+                let mut encoder = PrettyEncoder(wr);
+                animal.encode(&mut encoder);
             },
             ~"\
             [\n  \
@@ -1443,15 +1553,15 @@ mod tests {
     fn test_write_some() {
         let value = Some(~"jodhpurs");
         let s = do io::with_str_writer |wr| {
-            let encoder = Encoder(wr);
-            value.encode(&encoder);
+            let mut encoder = Encoder(wr);
+            value.encode(&mut encoder);
         };
         assert_eq!(s, ~"\"jodhpurs\"");
 
         let value = Some(~"jodhpurs");
         let s = do io::with_str_writer |wr| {
-            let encoder = PrettyEncoder(wr);
-            value.encode(&encoder);
+            let mut encoder = PrettyEncoder(wr);
+            value.encode(&mut encoder);
         };
         assert_eq!(s, ~"\"jodhpurs\"");
     }
@@ -1460,14 +1570,14 @@ mod tests {
     fn test_write_none() {
         let value: Option<~str> = None;
         let s = do io::with_str_writer |wr| {
-            let encoder = Encoder(wr);
-            value.encode(&encoder);
+            let mut encoder = Encoder(wr);
+            value.encode(&mut encoder);
         };
         assert_eq!(s, ~"null");
 
         let s = do io::with_str_writer |wr| {
-            let encoder = Encoder(wr);
-            value.encode(&encoder);
+            let mut encoder = Encoder(wr);
+            value.encode(&mut encoder);
         };
         assert_eq!(s, ~"null");
     }
@@ -1515,13 +1625,16 @@ mod tests {
 
     #[test]
     fn test_decode_identifiers() {
-        let v: () = Decodable::decode(&Decoder(from_str(~"null").unwrap()));
+        let mut decoder = Decoder(from_str(~"null").unwrap());
+        let v: () = Decodable::decode(&mut decoder);
         assert_eq!(v, ());
 
-        let v: bool = Decodable::decode(&Decoder(from_str(~"true").unwrap()));
+        let mut decoder = Decoder(from_str(~"true").unwrap());
+        let v: bool = Decodable::decode(&mut decoder);
         assert_eq!(v, true);
 
-        let v: bool = Decodable::decode(&Decoder(from_str(~"false").unwrap()));
+        let mut decoder = Decoder(from_str(~"false").unwrap());
+        let v: bool = Decodable::decode(&mut decoder);
         assert_eq!(v, false);
     }
 
@@ -1555,25 +1668,32 @@ mod tests {
 
     #[test]
     fn test_decode_numbers() {
-        let v: float = Decodable::decode(&Decoder(from_str(~"3").unwrap()));
+        let mut decoder = Decoder(from_str(~"3").unwrap());
+        let v: float = Decodable::decode(&mut decoder);
         assert_eq!(v, 3f);
 
-        let v: float = Decodable::decode(&Decoder(from_str(~"3.1").unwrap()));
+        let mut decoder = Decoder(from_str(~"3.1").unwrap());
+        let v: float = Decodable::decode(&mut decoder);
         assert_eq!(v, 3.1f);
 
-        let v: float = Decodable::decode(&Decoder(from_str(~"-1.2").unwrap()));
+        let mut decoder = Decoder(from_str(~"-1.2").unwrap());
+        let v: float = Decodable::decode(&mut decoder);
         assert_eq!(v, -1.2f);
 
-        let v: float = Decodable::decode(&Decoder(from_str(~"0.4").unwrap()));
+        let mut decoder = Decoder(from_str(~"0.4").unwrap());
+        let v: float = Decodable::decode(&mut decoder);
         assert_eq!(v, 0.4f);
 
-        let v: float = Decodable::decode(&Decoder(from_str(~"0.4e5").unwrap()));
+        let mut decoder = Decoder(from_str(~"0.4e5").unwrap());
+        let v: float = Decodable::decode(&mut decoder);
         assert_eq!(v, 0.4e5f);
 
-        let v: float = Decodable::decode(&Decoder(from_str(~"0.4e15").unwrap()));
+        let mut decoder = Decoder(from_str(~"0.4e15").unwrap());
+        let v: float = Decodable::decode(&mut decoder);
         assert_eq!(v, 0.4e15f);
 
-        let v: float = Decodable::decode(&Decoder(from_str(~"0.4e-01").unwrap()));
+        let mut decoder = Decoder(from_str(~"0.4e-01").unwrap());
+        let v: float = Decodable::decode(&mut decoder);
         assert_eq!(v, 0.4e-01f);
     }
 
@@ -1600,31 +1720,40 @@ mod tests {
 
     #[test]
     fn test_decode_str() {
-        let v: ~str = Decodable::decode(&Decoder(from_str(~"\"\"").unwrap()));
+        let mut decoder = Decoder(from_str(~"\"\"").unwrap());
+        let v: ~str = Decodable::decode(&mut decoder);
         assert_eq!(v, ~"");
 
-        let v: ~str = Decodable::decode(&Decoder(from_str(~"\"foo\"").unwrap()));
+        let mut decoder = Decoder(from_str(~"\"foo\"").unwrap());
+        let v: ~str = Decodable::decode(&mut decoder);
         assert_eq!(v, ~"foo");
 
-        let v: ~str = Decodable::decode(&Decoder(from_str(~"\"\\\"\"").unwrap()));
+        let mut decoder = Decoder(from_str(~"\"\\\"\"").unwrap());
+        let v: ~str = Decodable::decode(&mut decoder);
         assert_eq!(v, ~"\"");
 
-        let v: ~str = Decodable::decode(&Decoder(from_str(~"\"\\b\"").unwrap()));
+        let mut decoder = Decoder(from_str(~"\"\\b\"").unwrap());
+        let v: ~str = Decodable::decode(&mut decoder);
         assert_eq!(v, ~"\x08");
 
-        let v: ~str = Decodable::decode(&Decoder(from_str(~"\"\\n\"").unwrap()));
+        let mut decoder = Decoder(from_str(~"\"\\n\"").unwrap());
+        let v: ~str = Decodable::decode(&mut decoder);
         assert_eq!(v, ~"\n");
 
-        let v: ~str = Decodable::decode(&Decoder(from_str(~"\"\\r\"").unwrap()));
+        let mut decoder = Decoder(from_str(~"\"\\r\"").unwrap());
+        let v: ~str = Decodable::decode(&mut decoder);
         assert_eq!(v, ~"\r");
 
-        let v: ~str = Decodable::decode(&Decoder(from_str(~"\"\\t\"").unwrap()));
+        let mut decoder = Decoder(from_str(~"\"\\t\"").unwrap());
+        let v: ~str = Decodable::decode(&mut decoder);
         assert_eq!(v, ~"\t");
 
-        let v: ~str = Decodable::decode(&Decoder(from_str(~"\"\\u12ab\"").unwrap()));
+        let mut decoder = Decoder(from_str(~"\"\\u12ab\"").unwrap());
+        let v: ~str = Decodable::decode(&mut decoder);
         assert_eq!(v, ~"\u12ab");
 
-        let v: ~str = Decodable::decode(&Decoder(from_str(~"\"\\uAB12\"").unwrap()));
+        let mut decoder = Decoder(from_str(~"\"\\uAB12\"").unwrap());
+        let v: ~str = Decodable::decode(&mut decoder);
         assert_eq!(v, ~"\uAB12");
     }
 
@@ -1656,23 +1785,28 @@ mod tests {
 
     #[test]
     fn test_decode_list() {
-        let v: ~[()] = Decodable::decode(&Decoder(from_str(~"[]").unwrap()));
+        let mut decoder = Decoder(from_str(~"[]").unwrap());
+        let v: ~[()] = Decodable::decode(&mut decoder);
         assert_eq!(v, ~[]);
 
-        let v: ~[()] = Decodable::decode(&Decoder(from_str(~"[null]").unwrap()));
+        let mut decoder = Decoder(from_str(~"[null]").unwrap());
+        let v: ~[()] = Decodable::decode(&mut decoder);
         assert_eq!(v, ~[()]);
 
-
-        let v: ~[bool] = Decodable::decode(&Decoder(from_str(~"[true]").unwrap()));
+        let mut decoder = Decoder(from_str(~"[true]").unwrap());
+        let v: ~[bool] = Decodable::decode(&mut decoder);
         assert_eq!(v, ~[true]);
 
-        let v: ~[bool] = Decodable::decode(&Decoder(from_str(~"[true]").unwrap()));
+        let mut decoder = Decoder(from_str(~"[true]").unwrap());
+        let v: ~[bool] = Decodable::decode(&mut decoder);
         assert_eq!(v, ~[true]);
 
-        let v: ~[int] = Decodable::decode(&Decoder(from_str(~"[3, 1]").unwrap()));
+        let mut decoder = Decoder(from_str(~"[3, 1]").unwrap());
+        let v: ~[int] = Decodable::decode(&mut decoder);
         assert_eq!(v, ~[3, 1]);
 
-        let v: ~[~[uint]] = Decodable::decode(&Decoder(from_str(~"[[3], [1, 2]]").unwrap()));
+        let mut decoder = Decoder(from_str(~"[[3], [1, 2]]").unwrap());
+        let v: ~[~[uint]] = Decodable::decode(&mut decoder);
         assert_eq!(v, ~[~[3], ~[1, 2]]);
     }
 
@@ -1774,7 +1908,8 @@ mod tests {
                 { \"a\": null, \"b\": 2, \"c\": [\"abc\", \"xyz\"] }
             ]
         }";
-        let v: Outer = Decodable::decode(&Decoder(from_str(s).unwrap()));
+        let mut decoder = Decoder(from_str(s).unwrap());
+        let v: Outer = Decodable::decode(&mut decoder);
         assert_eq!(
             v,
             Outer {
@@ -1787,31 +1922,32 @@ mod tests {
 
     #[test]
     fn test_decode_option() {
-        let decoder = Decoder(from_str(~"null").unwrap());
-        let value: Option<~str> = Decodable::decode(&decoder);
+        let mut decoder = Decoder(from_str(~"null").unwrap());
+        let value: Option<~str> = Decodable::decode(&mut decoder);
         assert_eq!(value, None);
 
-        let decoder = Decoder(from_str(~"\"jodhpurs\"").unwrap());
-        let value: Option<~str> = Decodable::decode(&decoder);
+        let mut decoder = Decoder(from_str(~"\"jodhpurs\"").unwrap());
+        let value: Option<~str> = Decodable::decode(&mut decoder);
         assert_eq!(value, Some(~"jodhpurs"));
     }
 
     #[test]
     fn test_decode_enum() {
-        let decoder = Decoder(from_str(~"\"Dog\"").unwrap());
-        let value: Animal = Decodable::decode(&decoder);
+        let mut decoder = Decoder(from_str(~"\"Dog\"").unwrap());
+        let value: Animal = Decodable::decode(&mut decoder);
         assert_eq!(value, Dog);
 
-        let decoder = Decoder(from_str(~"[\"Frog\",\"Henry\",349]").unwrap());
-        let value: Animal = Decodable::decode(&decoder);
+        let mut decoder =
+            Decoder(from_str(~"[\"Frog\",\"Henry\",349]").unwrap());
+        let value: Animal = Decodable::decode(&mut decoder);
         assert_eq!(value, Frog(~"Henry", 349));
     }
 
     #[test]
     fn test_decode_map() {
         let s = ~"{\"a\": \"Dog\", \"b\": [\"Frog\", \"Henry\", 349]}";
-        let decoder = Decoder(from_str(s).unwrap());
-        let mut map: HashMap<~str, Animal> = Decodable::decode(&decoder);
+        let mut decoder = Decoder(from_str(s).unwrap());
+        let mut map: HashMap<~str, Animal> = Decodable::decode(&mut decoder);
 
         assert_eq!(map.pop(&~"a"), Some(Dog));
         assert_eq!(map.pop(&~"b"), Some(Frog(~"Henry", 349)));
diff --git a/src/libstd/list.rs b/src/libstd/list.rs
index 401cc121a62..8d15508b26e 100644
--- a/src/libstd/list.rs
+++ b/src/libstd/list.rs
@@ -16,6 +16,12 @@ pub enum List<T> {
     Nil,
 }
 
+#[deriving(Eq)]
+pub enum MutList<T> {
+    MutCons(T, @mut MutList<T>),
+    MutNil,
+}
+
 /// Create a list from a vector
 pub fn from_vec<T:Copy>(v: &[T]) -> @List<T> {
     vec::foldr(v, @Nil::<T>, |h, t| @Cons(*h, t))
@@ -147,6 +153,25 @@ pub fn each<T>(l: @List<T>, f: &fn(&T) -> bool) {
     }
 }
 
+impl<T> MutList<T> {
+    /// Iterate over a mutable list
+    pub fn each(@mut self, f: &fn(&mut T) -> bool) {
+        let mut cur = self;
+        loop {
+            let borrowed = &mut *cur;
+            cur = match *borrowed {
+                MutCons(ref mut hd, tl) => {
+                    if !f(hd) {
+                        return;
+                    }
+                    tl
+                }
+                MutNil => break
+            }
+        }
+    }
+}
+
 #[cfg(test)]
 mod tests {
     use list::*;
@@ -242,11 +267,3 @@ mod tests {
             == list::append(list::from_vec(~[1,2]), list::from_vec(~[3,4])));
     }
 }
-
-// Local Variables:
-// mode: rust;
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
diff --git a/src/libstd/net_tcp.rs b/src/libstd/net_tcp.rs
index ec4c025180c..53eb6c5561b 100644
--- a/src/libstd/net_tcp.rs
+++ b/src/libstd/net_tcp.rs
@@ -11,8 +11,6 @@
 //! High-level interface to libuv's TCP functionality
 // FIXME #4425: Need FFI fixes
 
-#[allow(deprecated_mode)];
-
 use future;
 use future_spawn = future::spawn;
 use ip = net_ip;
diff --git a/src/libstd/net_url.rs b/src/libstd/net_url.rs
index f3b11c13279..ba3fd69e344 100644
--- a/src/libstd/net_url.rs
+++ b/src/libstd/net_url.rs
@@ -10,18 +10,12 @@
 
 //! Types/fns concerning URLs (see RFC 3986)
 
-#[allow(deprecated_mode)];
-
 use core::cmp::Eq;
-use core::from_str::FromStr;
 use core::io::{Reader, ReaderUtil};
 use core::io;
 use core::hashmap::HashMap;
 use core::str;
-use core::to_bytes::IterBytes;
 use core::to_bytes;
-use core::to_str::ToStr;
-use core::to_str;
 use core::uint;
 
 #[deriving(Clone, Eq)]
@@ -703,13 +697,13 @@ pub fn to_str(url: &Url) -> ~str {
     fmt!("%s:%s%s%s%s", url.scheme, authority, url.path, query, fragment)
 }
 
-impl to_str::ToStr for Url {
+impl ToStr for Url {
     pub fn to_str(&self) -> ~str {
         to_str(self)
     }
 }
 
-impl to_bytes::IterBytes for Url {
+impl IterBytes for Url {
     fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
         self.to_str().iter_bytes(lsb0, f)
     }
diff --git a/src/libstd/num/bigint.rs b/src/libstd/num/bigint.rs
index e010340b94d..cd347098e25 100644
--- a/src/libstd/num/bigint.rs
+++ b/src/libstd/num/bigint.rs
@@ -21,7 +21,6 @@ A BigInt is a combination of BigUint and Sign.
 
 use core::cmp::{Eq, Ord, TotalEq, TotalOrd, Ordering, Less, Equal, Greater};
 use core::num::{IntConvertible, Zero, One, ToStrRadix, FromStrRadix};
-use core::*;
 
 /**
 A BigDigit is a BigUint's composing element.
@@ -80,6 +79,7 @@ A big unsigned integer type.
 A BigUint-typed value BigUint { data: @[a, b, c] } represents a number
 (a + b * BigDigit::base + c * BigDigit::base^2).
 */
+#[deriving(Clone)]
 pub struct BigUint {
     priv data: ~[BigDigit]
 }
@@ -140,7 +140,7 @@ impl ToStr for BigUint {
     fn to_str(&self) -> ~str { self.to_str_radix(10) }
 }
 
-impl from_str::FromStr for BigUint {
+impl FromStr for BigUint {
     #[inline(always)]
     fn from_str(s: &str) -> Option<BigUint> {
         FromStrRadix::from_str_radix(s, 10)
@@ -293,10 +293,10 @@ impl Mul<BigUint, BigUint> for BigUint {
     }
 }
 
-impl Quot<BigUint, BigUint> for BigUint {
+impl Div<BigUint, BigUint> for BigUint {
     #[inline(always)]
-    fn quot(&self, other: &BigUint) -> BigUint {
-        let (q, _) = self.quot_rem(other);
+    fn div(&self, other: &BigUint) -> BigUint {
+        let (q, _) = self.div_rem(other);
         return q;
     }
 }
@@ -304,7 +304,7 @@ impl Quot<BigUint, BigUint> for BigUint {
 impl Rem<BigUint, BigUint> for BigUint {
     #[inline(always)]
     fn rem(&self, other: &BigUint) -> BigUint {
-        let (_, r) = self.quot_rem(other);
+        let (_, r) = self.div_rem(other);
         return r;
     }
 }
@@ -316,19 +316,24 @@ impl Neg<BigUint> for BigUint {
 
 impl Integer for BigUint {
     #[inline(always)]
-    fn div(&self, other: &BigUint) -> BigUint {
-        let (d, _) = self.div_mod(other);
+    fn div_rem(&self, other: &BigUint) -> (BigUint, BigUint) {
+        self.div_mod_floor(other)
+    }
+
+    #[inline(always)]
+    fn div_floor(&self, other: &BigUint) -> BigUint {
+        let (d, _) = self.div_mod_floor(other);
         return d;
     }
 
     #[inline(always)]
-    fn modulo(&self, other: &BigUint) -> BigUint {
-        let (_, m) = self.div_mod(other);
+    fn mod_floor(&self, other: &BigUint) -> BigUint {
+        let (_, m) = self.div_mod_floor(other);
         return m;
     }
 
     #[inline(always)]
-    fn div_mod(&self, other: &BigUint) -> (BigUint, BigUint) {
+    fn div_mod_floor(&self, other: &BigUint) -> (BigUint, BigUint) {
         if other.is_zero() { fail!() }
         if self.is_zero() { return (Zero::zero(), Zero::zero()); }
         if *other == One::one() { return (copy *self, Zero::zero()); }
@@ -346,11 +351,11 @@ impl Integer for BigUint {
             shift += 1;
         }
         assert!(shift < BigDigit::bits);
-        let (d, m) = div_mod_inner(self << shift, other << shift);
+        let (d, m) = div_mod_floor_inner(self << shift, other << shift);
         return (d, m >> shift);
 
         #[inline(always)]
-        fn div_mod_inner(a: BigUint, b: BigUint) -> (BigUint, BigUint) {
+        fn div_mod_floor_inner(a: BigUint, b: BigUint) -> (BigUint, BigUint) {
             let mut m = a;
             let mut d = Zero::zero::<BigUint>();
             let mut n = 1;
@@ -409,11 +414,6 @@ impl Integer for BigUint {
         }
     }
 
-    #[inline(always)]
-    fn quot_rem(&self, other: &BigUint) -> (BigUint, BigUint) {
-        self.div_mod(other)
-    }
-
     /**
      * Calculates the Greatest Common Divisor (GCD) of the number and `other`
      *
@@ -485,7 +485,7 @@ impl ToStrRadix for BigUint {
             let mut result = ~[];
             let mut m      = n;
             while m > divider {
-                let (d, m0) = m.div_mod(&divider);
+                let (d, m0) = m.div_mod_floor(&divider);
                 result += [m0.to_uint() as BigDigit];
                 m = d;
             }
@@ -680,7 +680,7 @@ priv fn get_radix_base(radix: uint) -> (uint, uint) {
 }
 
 /// A Sign is a BigInt's composing element.
-#[deriving(Eq)]
+#[deriving(Eq, Clone)]
 pub enum Sign { Minus, Zero, Plus }
 
 impl Ord for Sign {
@@ -726,6 +726,7 @@ impl Neg<Sign> for Sign {
 }
 
 /// A big signed integer type.
+#[deriving(Clone)]
 pub struct BigInt {
     priv sign: Sign,
     priv data: BigUint
@@ -783,7 +784,7 @@ impl ToStr for BigInt {
     fn to_str(&self) -> ~str { self.to_str_radix(10) }
 }
 
-impl from_str::FromStr for BigInt {
+impl FromStr for BigInt {
     #[inline(always)]
     fn from_str(s: &str) -> Option<BigInt> {
         FromStrRadix::from_str_radix(s, 10)
@@ -825,8 +826,8 @@ impl Signed for BigInt {
     #[inline(always)]
     fn abs(&self) -> BigInt {
         match self.sign {
-            Plus | Zero => copy *self,
-            Minus => BigInt::from_biguint(Plus, copy self.data)
+            Plus | Zero => self.clone(),
+            Minus => BigInt::from_biguint(Plus, self.data.clone())
         }
     }
 
@@ -850,8 +851,8 @@ impl Add<BigInt, BigInt> for BigInt {
     #[inline(always)]
     fn add(&self, other: &BigInt) -> BigInt {
         match (self.sign, other.sign) {
-            (Zero, _)      => copy *other,
-            (_,    Zero)   => copy *self,
+            (Zero, _)      => other.clone(),
+            (_,    Zero)   => self.clone(),
             (Plus, Plus)   => BigInt::from_biguint(Plus,
                                                    self.data + other.data),
             (Plus, Minus)  => self - (-*other),
@@ -866,7 +867,7 @@ impl Sub<BigInt, BigInt> for BigInt {
     fn sub(&self, other: &BigInt) -> BigInt {
         match (self.sign, other.sign) {
             (Zero, _)    => -other,
-            (_,    Zero) => copy *self,
+            (_,    Zero) => self.clone(),
             (Plus, Plus) => match self.data.cmp(&other.data) {
                 Less    => BigInt::from_biguint(Minus, other.data - self.data),
                 Greater => BigInt::from_biguint(Plus, self.data - other.data),
@@ -894,10 +895,10 @@ impl Mul<BigInt, BigInt> for BigInt {
     }
 }
 
-impl Quot<BigInt, BigInt> for BigInt {
+impl Div<BigInt, BigInt> for BigInt {
     #[inline(always)]
-    fn quot(&self, other: &BigInt) -> BigInt {
-        let (q, _) = self.quot_rem(other);
+    fn div(&self, other: &BigInt) -> BigInt {
+        let (q, _) = self.div_rem(other);
         return q;
     }
 }
@@ -905,7 +906,7 @@ impl Quot<BigInt, BigInt> for BigInt {
 impl Rem<BigInt, BigInt> for BigInt {
     #[inline(always)]
     fn rem(&self, other: &BigInt) -> BigInt {
-        let (_, r) = self.quot_rem(other);
+        let (_, r) = self.div_rem(other);
         return r;
     }
 }
@@ -913,27 +914,42 @@ impl Rem<BigInt, BigInt> for BigInt {
 impl Neg<BigInt> for BigInt {
     #[inline(always)]
     fn neg(&self) -> BigInt {
-        BigInt::from_biguint(self.sign.neg(), copy self.data)
+        BigInt::from_biguint(self.sign.neg(), self.data.clone())
     }
 }
 
 impl Integer for BigInt {
     #[inline(always)]
-    fn div(&self, other: &BigInt) -> BigInt {
-        let (d, _) = self.div_mod(other);
+    fn div_rem(&self, other: &BigInt) -> (BigInt, BigInt) {
+        // r.sign == self.sign
+        let (d_ui, r_ui) = self.data.div_mod_floor(&other.data);
+        let d = BigInt::from_biguint(Plus, d_ui);
+        let r = BigInt::from_biguint(Plus, r_ui);
+        match (self.sign, other.sign) {
+            (_,    Zero)   => fail!(),
+            (Plus, Plus)  | (Zero, Plus)  => ( d,  r),
+            (Plus, Minus) | (Zero, Minus) => (-d,  r),
+            (Minus, Plus)                 => (-d, -r),
+            (Minus, Minus)                => ( d, -r)
+        }
+    }
+
+    #[inline(always)]
+    fn div_floor(&self, other: &BigInt) -> BigInt {
+        let (d, _) = self.div_mod_floor(other);
         return d;
     }
 
     #[inline(always)]
-    fn modulo(&self, other: &BigInt) -> BigInt {
-        let (_, m) = self.div_mod(other);
+    fn mod_floor(&self, other: &BigInt) -> BigInt {
+        let (_, m) = self.div_mod_floor(other);
         return m;
     }
 
     #[inline(always)]
-    fn div_mod(&self, other: &BigInt) -> (BigInt, BigInt) {
+    fn div_mod_floor(&self, other: &BigInt) -> (BigInt, BigInt) {
         // m.sign == other.sign
-        let (d_ui, m_ui) = self.data.quot_rem(&other.data);
+        let (d_ui, m_ui) = self.data.div_rem(&other.data);
         let d = BigInt::from_biguint(Plus, d_ui),
             m = BigInt::from_biguint(Plus, m_ui);
         match (self.sign, other.sign) {
@@ -953,21 +969,6 @@ impl Integer for BigInt {
         }
     }
 
-    #[inline(always)]
-    fn quot_rem(&self, other: &BigInt) -> (BigInt, BigInt) {
-        // r.sign == self.sign
-        let (q_ui, r_ui) = self.data.div_mod(&other.data);
-        let q = BigInt::from_biguint(Plus, q_ui);
-        let r = BigInt::from_biguint(Plus, r_ui);
-        match (self.sign, other.sign) {
-            (_,    Zero)   => fail!(),
-            (Plus, Plus)  | (Zero, Plus)  => ( q,  r),
-            (Plus, Minus) | (Zero, Minus) => (-q,  r),
-            (Minus, Plus)                 => (-q, -r),
-            (Minus, Minus)                => ( q, -r)
-        }
-    }
-
     /**
      * Calculates the Greatest Common Divisor (GCD) of the number and `other`
      *
@@ -1100,11 +1101,9 @@ pub impl BigInt {
 
 #[cfg(test)]
 mod biguint_tests {
-
-    use core::*;
+    use super::*;
     use core::num::{IntConvertible, Zero, One, FromStrRadix};
     use core::cmp::{Less, Equal, Greater};
-    use super::{BigUint, BigDigit};
 
     #[test]
     fn test_from_slice() {
@@ -1347,7 +1346,7 @@ mod biguint_tests {
         (&[ 0,  0,  1],     &[ 0,  0,  0,  1], &[0, 0,  0,  0,  0,  1])
     ];
 
-    static quot_rem_quadruples: &'static [(&'static [BigDigit],
+    static div_rem_quadruples: &'static [(&'static [BigDigit],
                                            &'static [BigDigit],
                                            &'static [BigDigit],
                                            &'static [BigDigit])]
@@ -1371,7 +1370,7 @@ mod biguint_tests {
             assert!(b * a == c);
         }
 
-        for quot_rem_quadruples.each |elm| {
+        for div_rem_quadruples.each |elm| {
             let (aVec, bVec, cVec, dVec) = *elm;
             let a = BigUint::from_slice(aVec);
             let b = BigUint::from_slice(bVec);
@@ -1384,7 +1383,7 @@ mod biguint_tests {
     }
 
     #[test]
-    fn test_quot_rem() {
+    fn test_div_rem() {
         for mul_triples.each |elm| {
             let (aVec, bVec, cVec) = *elm;
             let a = BigUint::from_slice(aVec);
@@ -1392,21 +1391,21 @@ mod biguint_tests {
             let c = BigUint::from_slice(cVec);
 
             if !a.is_zero() {
-                assert!(c.quot_rem(&a) == (copy b, Zero::zero()));
+                assert!(c.div_rem(&a) == (b.clone(), Zero::zero()));
             }
             if !b.is_zero() {
-                assert!(c.quot_rem(&b) == (copy a, Zero::zero()));
+                assert!(c.div_rem(&b) == (a.clone(), Zero::zero()));
             }
         }
 
-        for quot_rem_quadruples.each |elm| {
+        for div_rem_quadruples.each |elm| {
             let (aVec, bVec, cVec, dVec) = *elm;
             let a = BigUint::from_slice(aVec);
             let b = BigUint::from_slice(bVec);
             let c = BigUint::from_slice(cVec);
             let d = BigUint::from_slice(dVec);
 
-            if !b.is_zero() { assert!(a.quot_rem(&b) == (c, d)); }
+            if !b.is_zero() { assert!(a.div_rem(&b) == (c, d)); }
         }
     }
 
@@ -1557,8 +1556,7 @@ mod biguint_tests {
 
 #[cfg(test)]
 mod bigint_tests {
-    use super::{BigInt, BigUint, BigDigit, Sign, Minus, Zero, Plus};
-    use core::*;
+    use super::*;
     use core::cmp::{Less, Equal, Greater};
     use core::num::{IntConvertible, Zero, One, FromStrRadix};
 
@@ -1750,10 +1748,10 @@ mod bigint_tests {
         (&[ 0,  0,  1],     &[ 0,  0,  0,  1], &[0, 0,  0,  0,  0,  1])
     ];
 
-    static quot_rem_quadruples: &'static [(&'static [BigDigit],
-                                           &'static [BigDigit],
-                                           &'static [BigDigit],
-                                           &'static [BigDigit])]
+    static div_rem_quadruples: &'static [(&'static [BigDigit],
+                                          &'static [BigDigit],
+                                          &'static [BigDigit],
+                                          &'static [BigDigit])]
         = &[
             (&[ 1],        &[ 2], &[],               &[1]),
             (&[ 1,  1],    &[ 2], &[-1/2+1],         &[1]),
@@ -1777,7 +1775,7 @@ mod bigint_tests {
             assert!((-b) * a == -c);
         }
 
-        for quot_rem_quadruples.each |elm| {
+        for div_rem_quadruples.each |elm| {
             let (aVec, bVec, cVec, dVec) = *elm;
             let a = BigInt::from_slice(Plus, aVec);
             let b = BigInt::from_slice(Plus, bVec);
@@ -1790,9 +1788,9 @@ mod bigint_tests {
     }
 
     #[test]
-    fn test_div_mod() {
+    fn test_div_mod_floor() {
         fn check_sub(a: &BigInt, b: &BigInt, ans_d: &BigInt, ans_m: &BigInt) {
-            let (d, m) = a.div_mod(b);
+            let (d, m) = a.div_mod_floor(b);
             if !m.is_zero() {
                 assert!(m.sign == b.sign);
             }
@@ -1826,7 +1824,7 @@ mod bigint_tests {
             if !b.is_zero() { check(&c, &b, &a, &Zero::zero()); }
         }
 
-        for quot_rem_quadruples.each |elm| {
+        for div_rem_quadruples.each |elm| {
             let (aVec, bVec, cVec, dVec) = *elm;
             let a = BigInt::from_slice(Plus, aVec);
             let b = BigInt::from_slice(Plus, bVec);
@@ -1841,9 +1839,9 @@ mod bigint_tests {
 
 
     #[test]
-    fn test_quot_rem() {
+    fn test_div_rem() {
         fn check_sub(a: &BigInt, b: &BigInt, ans_q: &BigInt, ans_r: &BigInt) {
-            let (q, r) = a.quot_rem(b);
+            let (q, r) = a.div_rem(b);
             if !r.is_zero() {
                 assert!(r.sign == a.sign);
             }
@@ -1869,7 +1867,7 @@ mod bigint_tests {
             if !b.is_zero() { check(&c, &b, &a, &Zero::zero()); }
         }
 
-        for quot_rem_quadruples.each |elm| {
+        for div_rem_quadruples.each |elm| {
             let (aVec, bVec, cVec, dVec) = *elm;
             let a = BigInt::from_slice(Plus, aVec);
             let b = BigInt::from_slice(Plus, bVec);
@@ -1959,4 +1957,3 @@ mod bigint_tests {
         assert!(-Zero::zero::<BigInt>() == Zero::zero::<BigInt>());
     }
 }
-
diff --git a/src/libstd/num/complex.rs b/src/libstd/num/complex.rs
index 02393b15cca..41d2b4a101c 100644
--- a/src/libstd/num/complex.rs
+++ b/src/libstd/num/complex.rs
@@ -102,9 +102,9 @@ impl<T: Copy + Num> Mul<Cmplx<T>, Cmplx<T>> for Cmplx<T> {
 
 // (a + i b) / (c + i d) == [(a + i b) * (c - i d)] / (c*c + d*d)
 //   == [(a*c + b*d) / (c*c + d*d)] + i [(b*c - a*d) / (c*c + d*d)]
-impl<T: Copy + Num> Quot<Cmplx<T>, Cmplx<T>> for Cmplx<T> {
+impl<T: Copy + Num> Div<Cmplx<T>, Cmplx<T>> for Cmplx<T> {
     #[inline]
-    fn quot(&self, other: &Cmplx<T>) -> Cmplx<T> {
+    fn div(&self, other: &Cmplx<T>) -> Cmplx<T> {
         let norm_sqr = other.norm_sqr();
         Cmplx::new((self.re*other.re + self.im*other.im) / norm_sqr,
                      (self.im*other.re - self.re*other.im) / norm_sqr)
@@ -275,7 +275,7 @@ mod test {
             }
         }
         #[test]
-        fn test_quot() {
+        fn test_div() {
             assert_eq!(_neg1_1i / _0_1i, _1_1i);
             for all_consts.each |&c| {
                 if c != Zero::zero() {
diff --git a/src/libstd/num/rational.rs b/src/libstd/num/rational.rs
index a7c170c1cd6..9b92b7241b9 100644
--- a/src/libstd/num/rational.rs
+++ b/src/libstd/num/rational.rs
@@ -143,9 +143,9 @@ impl<T: Copy + Num + Ord>
 
 // (a/b) / (c/d) = (a*d)/(b*c)
 impl<T: Copy + Num + Ord>
-    Quot<Ratio<T>,Ratio<T>> for Ratio<T> {
+    Div<Ratio<T>,Ratio<T>> for Ratio<T> {
     #[inline]
-    fn quot(&self, rhs: &Ratio<T>) -> Ratio<T> {
+    fn div(&self, rhs: &Ratio<T>) -> Ratio<T> {
         Ratio::new(self.numer * rhs.denom, self.denom * rhs.numer)
     }
 }
@@ -395,7 +395,7 @@ mod test {
         }
 
         #[test]
-        fn test_quot() {
+        fn test_div() {
             assert_eq!(_1 / _1_2, _2);
             assert_eq!(_3_2 / _1_2, _1 + _2);
             assert_eq!(_1 / _neg1_2, _neg1_2 + _neg1_2 + _neg1_2 + _neg1_2);
@@ -424,7 +424,7 @@ mod test {
         }
         #[test]
         #[should_fail]
-        fn test_quot_0() {
+        fn test_div_0() {
             let _a =  _1 / _0;
         }
     }
diff --git a/src/libstd/serialize.rs b/src/libstd/serialize.rs
index 29d108e3ac2..a5d2604b6f6 100644
--- a/src/libstd/serialize.rs
+++ b/src/libstd/serialize.rs
@@ -24,377 +24,457 @@ use treemap::{TreeMap, TreeSet};
 
 pub trait Encoder {
     // Primitive types:
-    fn emit_nil(&self);
-    fn emit_uint(&self, v: uint);
-    fn emit_u64(&self, v: u64);
-    fn emit_u32(&self, v: u32);
-    fn emit_u16(&self, v: u16);
-    fn emit_u8(&self, v: u8);
-    fn emit_int(&self, v: int);
-    fn emit_i64(&self, v: i64);
-    fn emit_i32(&self, v: i32);
-    fn emit_i16(&self, v: i16);
-    fn emit_i8(&self, v: i8);
-    fn emit_bool(&self, v: bool);
-    fn emit_float(&self, v: float);
-    fn emit_f64(&self, v: f64);
-    fn emit_f32(&self, v: f32);
-    fn emit_char(&self, v: char);
-    fn emit_str(&self, v: &str);
+    fn emit_nil(&mut self);
+    fn emit_uint(&mut self, v: uint);
+    fn emit_u64(&mut self, v: u64);
+    fn emit_u32(&mut self, v: u32);
+    fn emit_u16(&mut self, v: u16);
+    fn emit_u8(&mut self, v: u8);
+    fn emit_int(&mut self, v: int);
+    fn emit_i64(&mut self, v: i64);
+    fn emit_i32(&mut self, v: i32);
+    fn emit_i16(&mut self, v: i16);
+    fn emit_i8(&mut self, v: i8);
+    fn emit_bool(&mut self, v: bool);
+    fn emit_float(&mut self, v: float);
+    fn emit_f64(&mut self, v: f64);
+    fn emit_f32(&mut self, v: f32);
+    fn emit_char(&mut self, v: char);
+    fn emit_str(&mut self, v: &str);
 
     // Compound types:
-    fn emit_enum(&self, name: &str, f: &fn());
-
-    fn emit_enum_variant(&self, v_name: &str, v_id: uint, len: uint, f: &fn());
-    fn emit_enum_variant_arg(&self, a_idx: uint, f: &fn());
-
-    fn emit_enum_struct_variant(&self, v_name: &str, v_id: uint, len: uint, f: &fn());
-    fn emit_enum_struct_variant_field(&self, f_name: &str, f_idx: uint, f: &fn());
-
-    fn emit_struct(&self, name: &str, len: uint, f: &fn());
-    fn emit_struct_field(&self, f_name: &str, f_idx: uint, f: &fn());
-
-    fn emit_tuple(&self, len: uint, f: &fn());
-    fn emit_tuple_arg(&self, idx: uint, f: &fn());
-
-    fn emit_tuple_struct(&self, name: &str, len: uint, f: &fn());
-    fn emit_tuple_struct_arg(&self, f_idx: uint, f: &fn());
+    fn emit_enum(&mut self, name: &str, f: &fn(&mut Self));
+
+    fn emit_enum_variant(&mut self,
+                         v_name: &str,
+                         v_id: uint,
+                         len: uint,
+                         f: &fn(&mut Self));
+    fn emit_enum_variant_arg(&mut self, a_idx: uint, f: &fn(&mut Self));
+
+    fn emit_enum_struct_variant(&mut self,
+                                v_name: &str,
+                                v_id: uint,
+                                len: uint,
+                                f: &fn(&mut Self));
+    fn emit_enum_struct_variant_field(&mut self,
+                                      f_name: &str,
+                                      f_idx: uint,
+                                      f: &fn(&mut Self));
+
+    fn emit_struct(&mut self, name: &str, len: uint, f: &fn(&mut Self));
+    fn emit_struct_field(&mut self,
+                         f_name: &str,
+                         f_idx: uint,
+                         f: &fn(&mut Self));
+
+    fn emit_tuple(&mut self, len: uint, f: &fn(&mut Self));
+    fn emit_tuple_arg(&mut self, idx: uint, f: &fn(&mut Self));
+
+    fn emit_tuple_struct(&mut self, name: &str, len: uint, f: &fn(&mut Self));
+    fn emit_tuple_struct_arg(&mut self, f_idx: uint, f: &fn(&mut Self));
 
     // Specialized types:
-    fn emit_option(&self, f: &fn());
-    fn emit_option_none(&self);
-    fn emit_option_some(&self, f: &fn());
+    fn emit_option(&mut self, f: &fn(&mut Self));
+    fn emit_option_none(&mut self);
+    fn emit_option_some(&mut self, f: &fn(&mut Self));
 
-    fn emit_seq(&self, len: uint, f: &fn());
-    fn emit_seq_elt(&self, idx: uint, f: &fn());
+    fn emit_seq(&mut self, len: uint, f: &fn(this: &mut Self));
+    fn emit_seq_elt(&mut self, idx: uint, f: &fn(this: &mut Self));
 
-    fn emit_map(&self, len: uint, f: &fn());
-    fn emit_map_elt_key(&self, idx: uint, f: &fn());
-    fn emit_map_elt_val(&self, idx: uint, f: &fn());
+    fn emit_map(&mut self, len: uint, f: &fn(&mut Self));
+    fn emit_map_elt_key(&mut self, idx: uint, f: &fn(&mut Self));
+    fn emit_map_elt_val(&mut self, idx: uint, f: &fn(&mut Self));
 }
 
 pub trait Decoder {
     // Primitive types:
-    fn read_nil(&self) -> ();
-    fn read_uint(&self) -> uint;
-    fn read_u64(&self) -> u64;
-    fn read_u32(&self) -> u32;
-    fn read_u16(&self) -> u16;
-    fn read_u8(&self) -> u8;
-    fn read_int(&self) -> int;
-    fn read_i64(&self) -> i64;
-    fn read_i32(&self) -> i32;
-    fn read_i16(&self) -> i16;
-    fn read_i8(&self) -> i8;
-    fn read_bool(&self) -> bool;
-    fn read_f64(&self) -> f64;
-    fn read_f32(&self) -> f32;
-    fn read_float(&self) -> float;
-    fn read_char(&self) -> char;
-    fn read_str(&self) -> ~str;
+    fn read_nil(&mut self) -> ();
+    fn read_uint(&mut self) -> uint;
+    fn read_u64(&mut self) -> u64;
+    fn read_u32(&mut self) -> u32;
+    fn read_u16(&mut self) -> u16;
+    fn read_u8(&mut self) -> u8;
+    fn read_int(&mut self) -> int;
+    fn read_i64(&mut self) -> i64;
+    fn read_i32(&mut self) -> i32;
+    fn read_i16(&mut self) -> i16;
+    fn read_i8(&mut self) -> i8;
+    fn read_bool(&mut self) -> bool;
+    fn read_f64(&mut self) -> f64;
+    fn read_f32(&mut self) -> f32;
+    fn read_float(&mut self) -> float;
+    fn read_char(&mut self) -> char;
+    fn read_str(&mut self) -> ~str;
 
     // Compound types:
-    fn read_enum<T>(&self, name: &str, f: &fn() -> T) -> T;
-
-    fn read_enum_variant<T>(&self, names: &[&str], f: &fn(uint) -> T) -> T;
-    fn read_enum_variant_arg<T>(&self, a_idx: uint, f: &fn() -> T) -> T;
-
-    fn read_enum_struct_variant<T>(&self, names: &[&str], f: &fn(uint) -> T) -> T;
-    fn read_enum_struct_variant_field<T>(&self, &f_name: &str, f_idx: uint, f: &fn() -> T) -> T;
-
-    fn read_struct<T>(&self, s_name: &str, len: uint, f: &fn() -> T) -> T;
-    fn read_struct_field<T>(&self, f_name: &str, f_idx: uint, f: &fn() -> T) -> T;
-
-    fn read_tuple<T>(&self, f: &fn(uint) -> T) -> T;
-    fn read_tuple_arg<T>(&self, a_idx: uint, f: &fn() -> T) -> T;
-
-    fn read_tuple_struct<T>(&self, s_name: &str, f: &fn(uint) -> T) -> T;
-    fn read_tuple_struct_arg<T>(&self, a_idx: uint, f: &fn() -> T) -> T;
+    fn read_enum<T>(&mut self, name: &str, f: &fn(&mut Self) -> T) -> T;
+
+    fn read_enum_variant<T>(&mut self,
+                            names: &[&str],
+                            f: &fn(&mut Self, uint) -> T)
+                            -> T;
+    fn read_enum_variant_arg<T>(&mut self,
+                                a_idx: uint,
+                                f: &fn(&mut Self) -> T)
+                                -> T;
+
+    fn read_enum_struct_variant<T>(&mut self,
+                                   names: &[&str],
+                                   f: &fn(&mut Self, uint) -> T)
+                                   -> T;
+    fn read_enum_struct_variant_field<T>(&mut self,
+                                         &f_name: &str,
+                                         f_idx: uint,
+                                         f: &fn(&mut Self) -> T)
+                                         -> T;
+
+    fn read_struct<T>(&mut self,
+                      s_name: &str,
+                      len: uint,
+                      f: &fn(&mut Self) -> T)
+                      -> T;
+    fn read_struct_field<T>(&mut self,
+                            f_name: &str,
+                            f_idx: uint,
+                            f: &fn(&mut Self) -> T)
+                            -> T;
+
+    fn read_tuple<T>(&mut self, f: &fn(&mut Self, uint) -> T) -> T;
+    fn read_tuple_arg<T>(&mut self, a_idx: uint, f: &fn(&mut Self) -> T) -> T;
+
+    fn read_tuple_struct<T>(&mut self,
+                            s_name: &str,
+                            f: &fn(&mut Self, uint) -> T)
+                            -> T;
+    fn read_tuple_struct_arg<T>(&mut self,
+                                a_idx: uint,
+                                f: &fn(&mut Self) -> T)
+                                -> T;
 
     // Specialized types:
-    fn read_option<T>(&self, f: &fn(bool) -> T) -> T;
+    fn read_option<T>(&mut self, f: &fn(&mut Self, bool) -> T) -> T;
 
-    fn read_seq<T>(&self, f: &fn(uint) -> T) -> T;
-    fn read_seq_elt<T>(&self, idx: uint, f: &fn() -> T) -> T;
+    fn read_seq<T>(&mut self, f: &fn(&mut Self, uint) -> T) -> T;
+    fn read_seq_elt<T>(&mut self, idx: uint, f: &fn(&mut Self) -> T) -> T;
 
-    fn read_map<T>(&self, f: &fn(uint) -> T) -> T;
-    fn read_map_elt_key<T>(&self, idx: uint, f: &fn() -> T) -> T;
-    fn read_map_elt_val<T>(&self, idx: uint, f: &fn() -> T) -> T;
+    fn read_map<T>(&mut self, f: &fn(&mut Self, uint) -> T) -> T;
+    fn read_map_elt_key<T>(&mut self, idx: uint, f: &fn(&mut Self) -> T) -> T;
+    fn read_map_elt_val<T>(&mut self, idx: uint, f: &fn(&mut Self) -> T) -> T;
 }
 
 pub trait Encodable<S:Encoder> {
-    fn encode(&self, s: &S);
+    fn encode(&self, s: &mut S);
 }
 
 pub trait Decodable<D:Decoder> {
-    fn decode(d: &D) -> Self;
+    fn decode(d: &mut D) -> Self;
 }
 
 impl<S:Encoder> Encodable<S> for uint {
-    fn encode(&self, s: &S) { s.emit_uint(*self) }
+    fn encode(&self, s: &mut S) {
+        s.emit_uint(*self)
+    }
 }
 
 impl<D:Decoder> Decodable<D> for uint {
-    fn decode(d: &D) -> uint {
+    fn decode(d: &mut D) -> uint {
         d.read_uint()
     }
 }
 
 impl<S:Encoder> Encodable<S> for u8 {
-    fn encode(&self, s: &S) { s.emit_u8(*self) }
+    fn encode(&self, s: &mut S) {
+        s.emit_u8(*self)
+    }
 }
 
 impl<D:Decoder> Decodable<D> for u8 {
-    fn decode(d: &D) -> u8 {
+    fn decode(d: &mut D) -> u8 {
         d.read_u8()
     }
 }
 
 impl<S:Encoder> Encodable<S> for u16 {
-    fn encode(&self, s: &S) { s.emit_u16(*self) }
+    fn encode(&self, s: &mut S) {
+        s.emit_u16(*self)
+    }
 }
 
 impl<D:Decoder> Decodable<D> for u16 {
-    fn decode(d: &D) -> u16 {
+    fn decode(d: &mut D) -> u16 {
         d.read_u16()
     }
 }
 
 impl<S:Encoder> Encodable<S> for u32 {
-    fn encode(&self, s: &S) { s.emit_u32(*self) }
+    fn encode(&self, s: &mut S) {
+        s.emit_u32(*self)
+    }
 }
 
 impl<D:Decoder> Decodable<D> for u32 {
-    fn decode(d: &D) -> u32 {
+    fn decode(d: &mut D) -> u32 {
         d.read_u32()
     }
 }
 
 impl<S:Encoder> Encodable<S> for u64 {
-    fn encode(&self, s: &S) { s.emit_u64(*self) }
+    fn encode(&self, s: &mut S) {
+        s.emit_u64(*self)
+    }
 }
 
 impl<D:Decoder> Decodable<D> for u64 {
-    fn decode(d: &D) -> u64 {
+    fn decode(d: &mut D) -> u64 {
         d.read_u64()
     }
 }
 
 impl<S:Encoder> Encodable<S> for int {
-    fn encode(&self, s: &S) { s.emit_int(*self) }
+    fn encode(&self, s: &mut S) {
+        s.emit_int(*self)
+    }
 }
 
 impl<D:Decoder> Decodable<D> for int {
-    fn decode(d: &D) -> int {
+    fn decode(d: &mut D) -> int {
         d.read_int()
     }
 }
 
 impl<S:Encoder> Encodable<S> for i8 {
-    fn encode(&self, s: &S) { s.emit_i8(*self) }
+    fn encode(&self, s: &mut S) {
+        s.emit_i8(*self)
+    }
 }
 
 impl<D:Decoder> Decodable<D> for i8 {
-    fn decode(d: &D) -> i8 {
+    fn decode(d: &mut D) -> i8 {
         d.read_i8()
     }
 }
 
 impl<S:Encoder> Encodable<S> for i16 {
-    fn encode(&self, s: &S) { s.emit_i16(*self) }
+    fn encode(&self, s: &mut S) {
+        s.emit_i16(*self)
+    }
 }
 
 impl<D:Decoder> Decodable<D> for i16 {
-    fn decode(d: &D) -> i16 {
+    fn decode(d: &mut D) -> i16 {
         d.read_i16()
     }
 }
 
 impl<S:Encoder> Encodable<S> for i32 {
-    fn encode(&self, s: &S) { s.emit_i32(*self) }
+    fn encode(&self, s: &mut S) {
+        s.emit_i32(*self)
+    }
 }
 
 impl<D:Decoder> Decodable<D> for i32 {
-    fn decode(d: &D) -> i32 {
+    fn decode(d: &mut D) -> i32 {
         d.read_i32()
     }
 }
 
 impl<S:Encoder> Encodable<S> for i64 {
-    fn encode(&self, s: &S) { s.emit_i64(*self) }
+    fn encode(&self, s: &mut S) {
+        s.emit_i64(*self)
+    }
 }
 
 impl<D:Decoder> Decodable<D> for i64 {
-    fn decode(d: &D) -> i64 {
+    fn decode(d: &mut D) -> i64 {
         d.read_i64()
     }
 }
 
 impl<'self, S:Encoder> Encodable<S> for &'self str {
-    fn encode(&self, s: &S) { s.emit_str(*self) }
+    fn encode(&self, s: &mut S) {
+        s.emit_str(*self)
+    }
 }
 
 impl<S:Encoder> Encodable<S> for ~str {
-    fn encode(&self, s: &S) { s.emit_str(*self) }
+    fn encode(&self, s: &mut S) {
+        s.emit_str(*self)
+    }
 }
 
 impl<D:Decoder> Decodable<D> for ~str {
-    fn decode(d: &D) -> ~str {
+    fn decode(d: &mut D) -> ~str {
         d.read_str()
     }
 }
 
 impl<S:Encoder> Encodable<S> for @str {
-    fn encode(&self, s: &S) { s.emit_str(*self) }
+    fn encode(&self, s: &mut S) {
+        s.emit_str(*self)
+    }
 }
 
 impl<D:Decoder> Decodable<D> for @str {
-    fn decode(d: &D) -> @str { d.read_str().to_managed() }
+    fn decode(d: &mut D) -> @str {
+        d.read_str().to_managed()
+    }
 }
 
 impl<S:Encoder> Encodable<S> for float {
-    fn encode(&self, s: &S) { s.emit_float(*self) }
+    fn encode(&self, s: &mut S) {
+        s.emit_float(*self)
+    }
 }
 
 impl<D:Decoder> Decodable<D> for float {
-    fn decode(d: &D) -> float {
+    fn decode(d: &mut D) -> float {
         d.read_float()
     }
 }
 
 impl<S:Encoder> Encodable<S> for f32 {
-    fn encode(&self, s: &S) { s.emit_f32(*self) }
+    fn encode(&self, s: &mut S) {
+        s.emit_f32(*self)
+    }
 }
 
 impl<D:Decoder> Decodable<D> for f32 {
-    fn decode(d: &D) -> f32 {
-        d.read_f32() }
+    fn decode(d: &mut D) -> f32 {
+        d.read_f32()
+    }
 }
 
 impl<S:Encoder> Encodable<S> for f64 {
-    fn encode(&self, s: &S) { s.emit_f64(*self) }
+    fn encode(&self, s: &mut S) {
+        s.emit_f64(*self)
+    }
 }
 
 impl<D:Decoder> Decodable<D> for f64 {
-    fn decode(d: &D) -> f64 {
+    fn decode(d: &mut D) -> f64 {
         d.read_f64()
     }
 }
 
 impl<S:Encoder> Encodable<S> for bool {
-    fn encode(&self, s: &S) { s.emit_bool(*self) }
+    fn encode(&self, s: &mut S) {
+        s.emit_bool(*self)
+    }
 }
 
 impl<D:Decoder> Decodable<D> for bool {
-    fn decode(d: &D) -> bool {
+    fn decode(d: &mut D) -> bool {
         d.read_bool()
     }
 }
 
 impl<S:Encoder> Encodable<S> for () {
-    fn encode(&self, s: &S) { s.emit_nil() }
+    fn encode(&self, s: &mut S) {
+        s.emit_nil()
+    }
 }
 
 impl<D:Decoder> Decodable<D> for () {
-    fn decode(d: &D) -> () {
+    fn decode(d: &mut D) -> () {
         d.read_nil()
     }
 }
 
 impl<'self, S:Encoder,T:Encodable<S>> Encodable<S> for &'self T {
-    fn encode(&self, s: &S) {
+    fn encode(&self, s: &mut S) {
         (**self).encode(s)
     }
 }
 
 impl<S:Encoder,T:Encodable<S>> Encodable<S> for ~T {
-    fn encode(&self, s: &S) {
+    fn encode(&self, s: &mut S) {
         (**self).encode(s)
     }
 }
 
 impl<D:Decoder,T:Decodable<D>> Decodable<D> for ~T {
-    fn decode(d: &D) -> ~T {
+    fn decode(d: &mut D) -> ~T {
         ~Decodable::decode(d)
     }
 }
 
 impl<S:Encoder,T:Encodable<S>> Encodable<S> for @T {
-    fn encode(&self, s: &S) {
+    fn encode(&self, s: &mut S) {
         (**self).encode(s)
     }
 }
 
 impl<D:Decoder,T:Decodable<D>> Decodable<D> for @T {
-    fn decode(d: &D) -> @T {
+    fn decode(d: &mut D) -> @T {
         @Decodable::decode(d)
     }
 }
 
 impl<'self, S:Encoder,T:Encodable<S>> Encodable<S> for &'self [T] {
-    fn encode(&self, s: &S) {
-        do s.emit_seq(self.len()) {
+    fn encode(&self, s: &mut S) {
+        do s.emit_seq(self.len()) |s| {
             for self.eachi |i, e| {
-                s.emit_seq_elt(i, || e.encode(s))
+                s.emit_seq_elt(i, |s| e.encode(s))
             }
         }
     }
 }
 
 impl<S:Encoder,T:Encodable<S>> Encodable<S> for ~[T] {
-    fn encode(&self, s: &S) {
-        do s.emit_seq(self.len()) {
+    fn encode(&self, s: &mut S) {
+        do s.emit_seq(self.len()) |s| {
             for self.eachi |i, e| {
-                s.emit_seq_elt(i, || e.encode(s))
+                s.emit_seq_elt(i, |s| e.encode(s))
             }
         }
     }
 }
 
 impl<D:Decoder,T:Decodable<D>> Decodable<D> for ~[T] {
-    fn decode(d: &D) -> ~[T] {
-        do d.read_seq |len| {
+    fn decode(d: &mut D) -> ~[T] {
+        do d.read_seq |d, len| {
             do vec::from_fn(len) |i| {
-                d.read_seq_elt(i, || Decodable::decode(d))
+                d.read_seq_elt(i, |d| Decodable::decode(d))
             }
         }
     }
 }
 
 impl<S:Encoder,T:Encodable<S>> Encodable<S> for @[T] {
-    fn encode(&self, s: &S) {
-        do s.emit_seq(self.len()) {
+    fn encode(&self, s: &mut S) {
+        do s.emit_seq(self.len()) |s| {
             for self.eachi |i, e| {
-                s.emit_seq_elt(i, || e.encode(s))
+                s.emit_seq_elt(i, |s| e.encode(s))
             }
         }
     }
 }
 
 impl<D:Decoder,T:Decodable<D>> Decodable<D> for @[T] {
-    fn decode(d: &D) -> @[T] {
-        do d.read_seq |len| {
+    fn decode(d: &mut D) -> @[T] {
+        do d.read_seq |d, len| {
             do at_vec::from_fn(len) |i| {
-                d.read_seq_elt(i, || Decodable::decode(d))
+                d.read_seq_elt(i, |d| Decodable::decode(d))
             }
         }
     }
 }
 
 impl<S:Encoder,T:Encodable<S>> Encodable<S> for Option<T> {
-    fn encode(&self, s: &S) {
-        do s.emit_option {
+    fn encode(&self, s: &mut S) {
+        do s.emit_option |s| {
             match *self {
                 None => s.emit_option_none(),
-                Some(ref v) => s.emit_option_some(|| v.encode(s)),
+                Some(ref v) => s.emit_option_some(|s| v.encode(s)),
             }
         }
     }
 }
 
 impl<D:Decoder,T:Decodable<D>> Decodable<D> for Option<T> {
-    fn decode(d: &D) -> Option<T> {
-        do d.read_option |b| {
+    fn decode(d: &mut D) -> Option<T> {
+        do d.read_option |d, b| {
             if b {
                 Some(Decodable::decode(d))
             } else {
@@ -405,12 +485,12 @@ impl<D:Decoder,T:Decodable<D>> Decodable<D> for Option<T> {
 }
 
 impl<S:Encoder,T0:Encodable<S>,T1:Encodable<S>> Encodable<S> for (T0, T1) {
-    fn encode(&self, s: &S) {
+    fn encode(&self, s: &mut S) {
         match *self {
             (ref t0, ref t1) => {
-                do s.emit_seq(2) {
-                    s.emit_seq_elt(0, || t0.encode(s));
-                    s.emit_seq_elt(1, || t1.encode(s));
+                do s.emit_seq(2) |s| {
+                    s.emit_seq_elt(0, |s| t0.encode(s));
+                    s.emit_seq_elt(1, |s| t1.encode(s));
                 }
             }
         }
@@ -418,12 +498,12 @@ impl<S:Encoder,T0:Encodable<S>,T1:Encodable<S>> Encodable<S> for (T0, T1) {
 }
 
 impl<D:Decoder,T0:Decodable<D>,T1:Decodable<D>> Decodable<D> for (T0, T1) {
-    fn decode(d: &D) -> (T0, T1) {
-        do d.read_seq |len| {
+    fn decode(d: &mut D) -> (T0, T1) {
+        do d.read_seq |d, len| {
             assert!(len == 2);
             (
-                d.read_seq_elt(0, || Decodable::decode(d)),
-                d.read_seq_elt(1, || Decodable::decode(d))
+                d.read_seq_elt(0, |d| Decodable::decode(d)),
+                d.read_seq_elt(1, |d| Decodable::decode(d))
             )
         }
     }
@@ -435,13 +515,13 @@ impl<
     T1: Encodable<S>,
     T2: Encodable<S>
 > Encodable<S> for (T0, T1, T2) {
-    fn encode(&self, s: &S) {
+    fn encode(&self, s: &mut S) {
         match *self {
             (ref t0, ref t1, ref t2) => {
-                do s.emit_seq(3) {
-                    s.emit_seq_elt(0, || t0.encode(s));
-                    s.emit_seq_elt(1, || t1.encode(s));
-                    s.emit_seq_elt(2, || t2.encode(s));
+                do s.emit_seq(3) |s| {
+                    s.emit_seq_elt(0, |s| t0.encode(s));
+                    s.emit_seq_elt(1, |s| t1.encode(s));
+                    s.emit_seq_elt(2, |s| t2.encode(s));
                 }
             }
         }
@@ -454,13 +534,13 @@ impl<
     T1: Decodable<D>,
     T2: Decodable<D>
 > Decodable<D> for (T0, T1, T2) {
-    fn decode(d: &D) -> (T0, T1, T2) {
-        do d.read_seq |len| {
+    fn decode(d: &mut D) -> (T0, T1, T2) {
+        do d.read_seq |d, len| {
             assert!(len == 3);
             (
-                d.read_seq_elt(0, || Decodable::decode(d)),
-                d.read_seq_elt(1, || Decodable::decode(d)),
-                d.read_seq_elt(2, || Decodable::decode(d))
+                d.read_seq_elt(0, |d| Decodable::decode(d)),
+                d.read_seq_elt(1, |d| Decodable::decode(d)),
+                d.read_seq_elt(2, |d| Decodable::decode(d))
             )
         }
     }
@@ -473,14 +553,14 @@ impl<
     T2: Encodable<S>,
     T3: Encodable<S>
 > Encodable<S> for (T0, T1, T2, T3) {
-    fn encode(&self, s: &S) {
+    fn encode(&self, s: &mut S) {
         match *self {
             (ref t0, ref t1, ref t2, ref t3) => {
-                do s.emit_seq(4) {
-                    s.emit_seq_elt(0, || t0.encode(s));
-                    s.emit_seq_elt(1, || t1.encode(s));
-                    s.emit_seq_elt(2, || t2.encode(s));
-                    s.emit_seq_elt(3, || t3.encode(s));
+                do s.emit_seq(4) |s| {
+                    s.emit_seq_elt(0, |s| t0.encode(s));
+                    s.emit_seq_elt(1, |s| t1.encode(s));
+                    s.emit_seq_elt(2, |s| t2.encode(s));
+                    s.emit_seq_elt(3, |s| t3.encode(s));
                 }
             }
         }
@@ -494,14 +574,14 @@ impl<
     T2: Decodable<D>,
     T3: Decodable<D>
 > Decodable<D> for (T0, T1, T2, T3) {
-    fn decode(d: &D) -> (T0, T1, T2, T3) {
-        do d.read_seq |len| {
+    fn decode(d: &mut D) -> (T0, T1, T2, T3) {
+        do d.read_seq |d, len| {
             assert!(len == 4);
             (
-                d.read_seq_elt(0, || Decodable::decode(d)),
-                d.read_seq_elt(1, || Decodable::decode(d)),
-                d.read_seq_elt(2, || Decodable::decode(d)),
-                d.read_seq_elt(3, || Decodable::decode(d))
+                d.read_seq_elt(0, |d| Decodable::decode(d)),
+                d.read_seq_elt(1, |d| Decodable::decode(d)),
+                d.read_seq_elt(2, |d| Decodable::decode(d)),
+                d.read_seq_elt(3, |d| Decodable::decode(d))
             )
         }
     }
@@ -515,15 +595,15 @@ impl<
     T3: Encodable<S>,
     T4: Encodable<S>
 > Encodable<S> for (T0, T1, T2, T3, T4) {
-    fn encode(&self, s: &S) {
+    fn encode(&self, s: &mut S) {
         match *self {
             (ref t0, ref t1, ref t2, ref t3, ref t4) => {
-                do s.emit_seq(5) {
-                    s.emit_seq_elt(0, || t0.encode(s));
-                    s.emit_seq_elt(1, || t1.encode(s));
-                    s.emit_seq_elt(2, || t2.encode(s));
-                    s.emit_seq_elt(3, || t3.encode(s));
-                    s.emit_seq_elt(4, || t4.encode(s));
+                do s.emit_seq(5) |s| {
+                    s.emit_seq_elt(0, |s| t0.encode(s));
+                    s.emit_seq_elt(1, |s| t1.encode(s));
+                    s.emit_seq_elt(2, |s| t2.encode(s));
+                    s.emit_seq_elt(3, |s| t3.encode(s));
+                    s.emit_seq_elt(4, |s| t4.encode(s));
                 }
             }
         }
@@ -538,16 +618,15 @@ impl<
     T3: Decodable<D>,
     T4: Decodable<D>
 > Decodable<D> for (T0, T1, T2, T3, T4) {
-    fn decode(d: &D)
-      -> (T0, T1, T2, T3, T4) {
-        do d.read_seq |len| {
+    fn decode(d: &mut D) -> (T0, T1, T2, T3, T4) {
+        do d.read_seq |d, len| {
             assert!(len == 5);
             (
-                d.read_seq_elt(0, || Decodable::decode(d)),
-                d.read_seq_elt(1, || Decodable::decode(d)),
-                d.read_seq_elt(2, || Decodable::decode(d)),
-                d.read_seq_elt(3, || Decodable::decode(d)),
-                d.read_seq_elt(4, || Decodable::decode(d))
+                d.read_seq_elt(0, |d| Decodable::decode(d)),
+                d.read_seq_elt(1, |d| Decodable::decode(d)),
+                d.read_seq_elt(2, |d| Decodable::decode(d)),
+                d.read_seq_elt(3, |d| Decodable::decode(d)),
+                d.read_seq_elt(4, |d| Decodable::decode(d))
             )
         }
     }
@@ -557,11 +636,11 @@ impl<
     S: Encoder,
     T: Encodable<S> + Copy
 > Encodable<S> for @mut DList<T> {
-    fn encode(&self, s: &S) {
-        do s.emit_seq(self.size) {
+    fn encode(&self, s: &mut S) {
+        do s.emit_seq(self.size) |s| {
             let mut i = 0;
             for self.each |e| {
-                s.emit_seq_elt(i, || e.encode(s));
+                s.emit_seq_elt(i, |s| e.encode(s));
                 i += 1;
             }
         }
@@ -569,11 +648,11 @@ impl<
 }
 
 impl<D:Decoder,T:Decodable<D>> Decodable<D> for @mut DList<T> {
-    fn decode(d: &D) -> @mut DList<T> {
+    fn decode(d: &mut D) -> @mut DList<T> {
         let list = DList();
-        do d.read_seq |len| {
+        do d.read_seq |d, len| {
             for uint::range(0, len) |i| {
-                list.push(d.read_seq_elt(i, || Decodable::decode(d)));
+                list.push(d.read_seq_elt(i, |d| Decodable::decode(d)));
             }
         }
         list
@@ -584,21 +663,21 @@ impl<
     S: Encoder,
     T: Encodable<S>
 > Encodable<S> for Deque<T> {
-    fn encode(&self, s: &S) {
-        do s.emit_seq(self.len()) {
+    fn encode(&self, s: &mut S) {
+        do s.emit_seq(self.len()) |s| {
             for self.eachi |i, e| {
-                s.emit_seq_elt(i, || e.encode(s));
+                s.emit_seq_elt(i, |s| e.encode(s));
             }
         }
     }
 }
 
 impl<D:Decoder,T:Decodable<D>> Decodable<D> for Deque<T> {
-    fn decode(d: &D) -> Deque<T> {
+    fn decode(d: &mut D) -> Deque<T> {
         let mut deque = Deque::new();
-        do d.read_seq |len| {
+        do d.read_seq |d, len| {
             for uint::range(0, len) |i| {
-                deque.add_back(d.read_seq_elt(i, || Decodable::decode(d)));
+                deque.add_back(d.read_seq_elt(i, |d| Decodable::decode(d)));
             }
         }
         deque
@@ -610,12 +689,12 @@ impl<
     K: Encodable<E> + Hash + IterBytes + Eq,
     V: Encodable<E>
 > Encodable<E> for HashMap<K, V> {
-    fn encode(&self, e: &E) {
-        do e.emit_map(self.len()) {
+    fn encode(&self, e: &mut E) {
+        do e.emit_map(self.len()) |e| {
             let mut i = 0;
             for self.each |key, val| {
-                e.emit_map_elt_key(i, || key.encode(e));
-                e.emit_map_elt_val(i, || val.encode(e));
+                e.emit_map_elt_key(i, |e| key.encode(e));
+                e.emit_map_elt_val(i, |e| val.encode(e));
                 i += 1;
             }
         }
@@ -627,12 +706,12 @@ impl<
     K: Decodable<D> + Hash + IterBytes + Eq,
     V: Decodable<D>
 > Decodable<D> for HashMap<K, V> {
-    fn decode(d: &D) -> HashMap<K, V> {
-        do d.read_map |len| {
+    fn decode(d: &mut D) -> HashMap<K, V> {
+        do d.read_map |d, len| {
             let mut map = HashMap::with_capacity(len);
             for uint::range(0, len) |i| {
-                let key = d.read_map_elt_key(i, || Decodable::decode(d));
-                let val = d.read_map_elt_val(i, || Decodable::decode(d));
+                let key = d.read_map_elt_key(i, |d| Decodable::decode(d));
+                let val = d.read_map_elt_val(i, |d| Decodable::decode(d));
                 map.insert(key, val);
             }
             map
@@ -644,11 +723,11 @@ impl<
     S: Encoder,
     T: Encodable<S> + Hash + IterBytes + Eq
 > Encodable<S> for HashSet<T> {
-    fn encode(&self, s: &S) {
-        do s.emit_seq(self.len()) {
+    fn encode(&self, s: &mut S) {
+        do s.emit_seq(self.len()) |s| {
             let mut i = 0;
             for self.each |e| {
-                s.emit_seq_elt(i, || e.encode(s));
+                s.emit_seq_elt(i, |s| e.encode(s));
                 i += 1;
             }
         }
@@ -659,11 +738,11 @@ impl<
     D: Decoder,
     T: Decodable<D> + Hash + IterBytes + Eq
 > Decodable<D> for HashSet<T> {
-    fn decode(d: &D) -> HashSet<T> {
-        do d.read_seq |len| {
+    fn decode(d: &mut D) -> HashSet<T> {
+        do d.read_seq |d, len| {
             let mut set = HashSet::with_capacity(len);
             for uint::range(0, len) |i| {
-                set.insert(d.read_seq_elt(i, || Decodable::decode(d)));
+                set.insert(d.read_seq_elt(i, |d| Decodable::decode(d)));
             }
             set
         }
@@ -674,12 +753,12 @@ impl<
     E: Encoder,
     V: Encodable<E>
 > Encodable<E> for TrieMap<V> {
-    fn encode(&self, e: &E) {
-        do e.emit_map(self.len()) {
+    fn encode(&self, e: &mut E) {
+        do e.emit_map(self.len()) |e| {
             let mut i = 0;
             for self.each |key, val| {
-                e.emit_map_elt_key(i, || key.encode(e));
-                e.emit_map_elt_val(i, || val.encode(e));
+                e.emit_map_elt_key(i, |e| key.encode(e));
+                e.emit_map_elt_val(i, |e| val.encode(e));
                 i += 1;
             }
         }
@@ -690,12 +769,12 @@ impl<
     D: Decoder,
     V: Decodable<D>
 > Decodable<D> for TrieMap<V> {
-    fn decode(d: &D) -> TrieMap<V> {
-        do d.read_map |len| {
+    fn decode(d: &mut D) -> TrieMap<V> {
+        do d.read_map |d, len| {
             let mut map = TrieMap::new();
             for uint::range(0, len) |i| {
-                let key = d.read_map_elt_key(i, || Decodable::decode(d));
-                let val = d.read_map_elt_val(i, || Decodable::decode(d));
+                let key = d.read_map_elt_key(i, |d| Decodable::decode(d));
+                let val = d.read_map_elt_val(i, |d| Decodable::decode(d));
                 map.insert(key, val);
             }
             map
@@ -704,11 +783,11 @@ impl<
 }
 
 impl<S: Encoder> Encodable<S> for TrieSet {
-    fn encode(&self, s: &S) {
-        do s.emit_seq(self.len()) {
+    fn encode(&self, s: &mut S) {
+        do s.emit_seq(self.len()) |s| {
             let mut i = 0;
             for self.each |e| {
-                s.emit_seq_elt(i, || e.encode(s));
+                s.emit_seq_elt(i, |s| e.encode(s));
                 i += 1;
             }
         }
@@ -716,11 +795,11 @@ impl<S: Encoder> Encodable<S> for TrieSet {
 }
 
 impl<D: Decoder> Decodable<D> for TrieSet {
-    fn decode(d: &D) -> TrieSet {
-        do d.read_seq |len| {
+    fn decode(d: &mut D) -> TrieSet {
+        do d.read_seq |d, len| {
             let mut set = TrieSet::new();
             for uint::range(0, len) |i| {
-                set.insert(d.read_seq_elt(i, || Decodable::decode(d)));
+                set.insert(d.read_seq_elt(i, |d| Decodable::decode(d)));
             }
             set
         }
@@ -732,12 +811,12 @@ impl<
     K: Encodable<E> + Eq + TotalOrd,
     V: Encodable<E> + Eq
 > Encodable<E> for TreeMap<K, V> {
-    fn encode(&self, e: &E) {
-        do e.emit_map(self.len()) {
+    fn encode(&self, e: &mut E) {
+        do e.emit_map(self.len()) |e| {
             let mut i = 0;
             for self.each |key, val| {
-                e.emit_map_elt_key(i, || key.encode(e));
-                e.emit_map_elt_val(i, || val.encode(e));
+                e.emit_map_elt_key(i, |e| key.encode(e));
+                e.emit_map_elt_val(i, |e| val.encode(e));
                 i += 1;
             }
         }
@@ -749,12 +828,12 @@ impl<
     K: Decodable<D> + Eq + TotalOrd,
     V: Decodable<D> + Eq
 > Decodable<D> for TreeMap<K, V> {
-    fn decode(d: &D) -> TreeMap<K, V> {
-        do d.read_map |len| {
+    fn decode(d: &mut D) -> TreeMap<K, V> {
+        do d.read_map |d, len| {
             let mut map = TreeMap::new();
             for uint::range(0, len) |i| {
-                let key = d.read_map_elt_key(i, || Decodable::decode(d));
-                let val = d.read_map_elt_val(i, || Decodable::decode(d));
+                let key = d.read_map_elt_key(i, |d| Decodable::decode(d));
+                let val = d.read_map_elt_val(i, |d| Decodable::decode(d));
                 map.insert(key, val);
             }
             map
@@ -766,11 +845,11 @@ impl<
     S: Encoder,
     T: Encodable<S> + Eq + TotalOrd
 > Encodable<S> for TreeSet<T> {
-    fn encode(&self, s: &S) {
-        do s.emit_seq(self.len()) {
+    fn encode(&self, s: &mut S) {
+        do s.emit_seq(self.len()) |s| {
             let mut i = 0;
             for self.each |e| {
-                s.emit_seq_elt(i, || e.encode(s));
+                s.emit_seq_elt(i, |s| e.encode(s));
                 i += 1;
             }
         }
@@ -781,11 +860,11 @@ impl<
     D: Decoder,
     T: Decodable<D> + Eq + TotalOrd
 > Decodable<D> for TreeSet<T> {
-    fn decode(d: &D) -> TreeSet<T> {
-        do d.read_seq |len| {
+    fn decode(d: &mut D) -> TreeSet<T> {
+        do d.read_seq |d, len| {
             let mut set = TreeSet::new();
             for uint::range(0, len) |i| {
-                set.insert(d.read_seq_elt(i, || Decodable::decode(d)));
+                set.insert(d.read_seq_elt(i, |d| Decodable::decode(d)));
             }
             set
         }
@@ -798,15 +877,15 @@ impl<
 // In some cases, these should eventually be coded as traits.
 
 pub trait EncoderHelpers {
-    fn emit_from_vec<T>(&self, v: &[T], f: &fn(v: &T));
+    fn emit_from_vec<T>(&mut self, v: &[T], f: &fn(&mut Self, v: &T));
 }
 
 impl<S:Encoder> EncoderHelpers for S {
-    fn emit_from_vec<T>(&self, v: &[T], f: &fn(v: &T)) {
-        do self.emit_seq(v.len()) {
+    fn emit_from_vec<T>(&mut self, v: &[T], f: &fn(&mut S, &T)) {
+        do self.emit_seq(v.len()) |this| {
             for v.eachi |i, e| {
-                do self.emit_seq_elt(i) {
-                    f(e)
+                do this.emit_seq_elt(i) |this| {
+                    f(this, e)
                 }
             }
         }
@@ -814,14 +893,14 @@ impl<S:Encoder> EncoderHelpers for S {
 }
 
 pub trait DecoderHelpers {
-    fn read_to_vec<T>(&self, f: &fn() -> T) -> ~[T];
+    fn read_to_vec<T>(&mut self, f: &fn(&mut Self) -> T) -> ~[T];
 }
 
 impl<D:Decoder> DecoderHelpers for D {
-    fn read_to_vec<T>(&self, f: &fn() -> T) -> ~[T] {
-        do self.read_seq |len| {
+    fn read_to_vec<T>(&mut self, f: &fn(&mut D) -> T) -> ~[T] {
+        do self.read_seq |this, len| {
             do vec::from_fn(len) |i| {
-                self.read_seq_elt(i, || f())
+                this.read_seq_elt(i, |this| f(this))
             }
         }
     }
diff --git a/src/libstd/sha1.rs b/src/libstd/sha1.rs
index 7371250b38a..a8e0f7d062a 100644
--- a/src/libstd/sha1.rs
+++ b/src/libstd/sha1.rs
@@ -412,11 +412,3 @@ mod tests {
         }
     }
 }
-
-// Local Variables:
-// mode: rust;
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
diff --git a/src/libstd/sort.rs b/src/libstd/sort.rs
index 119b47c904e..a18e2f47a77 100644
--- a/src/libstd/sort.rs
+++ b/src/libstd/sort.rs
@@ -1236,11 +1236,3 @@ mod big_tests {
         }
     }
 }
-
-// Local Variables:
-// mode: rust;
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
diff --git a/src/libstd/std.rc b/src/libstd/std.rc
index 9d1ddb8ec54..a326af804bd 100644
--- a/src/libstd/std.rc
+++ b/src/libstd/std.rc
@@ -124,11 +124,3 @@ pub mod std {
     pub use serialize;
     pub use test;
 }
-
-// Local Variables:
-// mode: rust;
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
diff --git a/src/libstd/task_pool.rs b/src/libstd/task_pool.rs
index 82053602755..661247df1c1 100644
--- a/src/libstd/task_pool.rs
+++ b/src/libstd/task_pool.rs
@@ -100,4 +100,3 @@ fn test_task_pool() {
         pool.execute(|i| io::println(fmt!("Hello from thread %u!", *i)));
     }
 }
-
diff --git a/src/libstd/tempfile.rs b/src/libstd/tempfile.rs
index eec91b68454..10645e947e2 100644
--- a/src/libstd/tempfile.rs
+++ b/src/libstd/tempfile.rs
@@ -27,6 +27,7 @@ pub fn mkdtemp(tmpdir: &Path, suffix: &str) -> Option<Path> {
 mod tests {
     use tempfile::mkdtemp;
     use tempfile;
+    use core::os;
 
     #[test]
     fn test_mkdtemp() {
@@ -42,13 +43,18 @@ mod tests {
         use core::libc::consts::os::posix88::{S_IRUSR, S_IWUSR, S_IXUSR};
         use core::os;
 
-        let root = mkdtemp(&os::tmpdir(), "temp").expect("recursive_mkdir_rel");
-        os::change_dir(&root);
-        let path = Path("frob");
-        assert!(os::mkdir_recursive(&path,  (S_IRUSR | S_IWUSR | S_IXUSR) as i32));
-        assert!(os::path_is_dir(&path));
-        assert!(os::mkdir_recursive(&path,  (S_IRUSR | S_IWUSR | S_IXUSR) as i32));
-        assert!(os::path_is_dir(&path));
+        let root = mkdtemp(&os::tmpdir(), "recursive_mkdir_rel").
+            expect("recursive_mkdir_rel");
+        assert!(do os::change_dir_locked(&root) {
+            let path = Path("frob");
+            debug!("recursive_mkdir_rel: Making: %s in cwd %s [%?]", path.to_str(),
+                   os::getcwd().to_str(),
+                   os::path_exists(&path));
+            assert!(os::mkdir_recursive(&path,  (S_IRUSR | S_IWUSR | S_IXUSR) as i32));
+            assert!(os::path_is_dir(&path));
+            assert!(os::mkdir_recursive(&path,  (S_IRUSR | S_IWUSR | S_IXUSR) as i32));
+            assert!(os::path_is_dir(&path));
+        });
     }
 
     #[test]
@@ -67,18 +73,44 @@ mod tests {
         use core::libc::consts::os::posix88::{S_IRUSR, S_IWUSR, S_IXUSR};
         use core::os;
 
-        let root = mkdtemp(&os::tmpdir(), "temp").expect("recursive_mkdir_rel_2");
-        os::change_dir(&root);
-        let path = Path("./frob/baz");
-        debug!("...Making: %s in cwd %s", path.to_str(), os::getcwd().to_str());
-        assert!(os::mkdir_recursive(&path, (S_IRUSR | S_IWUSR | S_IXUSR) as i32));
-        assert!(os::path_is_dir(&path));
-        assert!(os::path_is_dir(&path.pop()));
-        let path2 = Path("quux/blat");
-        debug!("Making: %s in cwd %s", path2.to_str(), os::getcwd().to_str());
-        assert!(os::mkdir_recursive(&path2, (S_IRUSR | S_IWUSR | S_IXUSR) as i32));
-        assert!(os::path_is_dir(&path2));
-        assert!(os::path_is_dir(&path2.pop()));
+        let root = mkdtemp(&os::tmpdir(), "recursive_mkdir_rel_2").
+            expect("recursive_mkdir_rel_2");
+        assert!(do os::change_dir_locked(&root) {
+            let path = Path("./frob/baz");
+            debug!("recursive_mkdir_rel_2: Making: %s in cwd %s [%?]", path.to_str(),
+                   os::getcwd().to_str(), os::path_exists(&path));
+            assert!(os::mkdir_recursive(&path, (S_IRUSR | S_IWUSR | S_IXUSR) as i32));
+                assert!(os::path_is_dir(&path));
+            assert!(os::path_is_dir(&path.pop()));
+            let path2 = Path("quux/blat");
+            debug!("recursive_mkdir_rel_2: Making: %s in cwd %s", path2.to_str(),
+                   os::getcwd().to_str());
+            assert!(os::mkdir_recursive(&path2, (S_IRUSR | S_IWUSR | S_IXUSR) as i32));
+                assert!(os::path_is_dir(&path2));
+            assert!(os::path_is_dir(&path2.pop()));
+        });
     }
 
-}
\ No newline at end of file
+    // Ideally this would be in core, but needs mkdtemp
+    #[test]
+    pub fn test_rmdir_recursive_ok() {
+        use core::libc::consts::os::posix88::{S_IRUSR, S_IWUSR, S_IXUSR};
+        use core::os;
+
+        let rwx = (S_IRUSR | S_IWUSR | S_IXUSR) as i32;
+
+        let tmpdir = mkdtemp(&os::tmpdir(), "test").expect("test_rmdir_recursive_ok: \
+                                            couldn't create temp dir");
+        let root = tmpdir.push("foo");
+
+        debug!("making %s", root.to_str());
+        assert!(os::make_dir(&root, rwx));
+        assert!(os::make_dir(&root.push("foo"), rwx));
+        assert!(os::make_dir(&root.push("foo").push("bar"), rwx));
+        assert!(os::make_dir(&root.push("foo").push("bar").push("blat"), rwx));
+        assert!(os::remove_dir_recursive(&root));
+        assert!(!os::path_exists(&root));
+        assert!(!os::path_exists(&root.push("bar")));
+        assert!(!os::path_exists(&root.push("bar").push("blat")));
+    }
+}
diff --git a/src/libstd/term.rs b/src/libstd/term.rs
index 022f1f8564e..a79b9f4c849 100644
--- a/src/libstd/term.rs
+++ b/src/libstd/term.rs
@@ -76,10 +76,3 @@ pub fn fg(writer: @io::Writer, color: u8) {
 pub fn bg(writer: @io::Writer, color: u8) {
     return set_color(writer, '4' as u8, color);
 }
-
-// Local Variables:
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
diff --git a/src/libstd/test.rs b/src/libstd/test.rs
index 278a326d1de..65fb0c7426a 100644
--- a/src/libstd/test.rs
+++ b/src/libstd/test.rs
@@ -960,12 +960,3 @@ mod tests {
         }
     }
 }
-
-
-// Local Variables:
-// mode: rust;
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
diff --git a/src/libstd/workcache.rs b/src/libstd/workcache.rs
index c01d1f5a2d7..e681382ffc8 100644
--- a/src/libstd/workcache.rs
+++ b/src/libstd/workcache.rs
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#[allow(deprecated_mode)];
-
 use json;
 use sha1;
 use serialize::{Encoder, Encodable, Decoder, Decodable};
@@ -141,7 +139,7 @@ impl WorkMap {
 }
 
 impl<S:Encoder> Encodable<S> for WorkMap {
-    fn encode(&self, s: &S) {
+    fn encode(&self, s: &mut S) {
         let mut d = ~[];
         for self.each |k, v| {
             d.push((copy *k, copy *v))
@@ -152,7 +150,7 @@ impl<S:Encoder> Encodable<S> for WorkMap {
 }
 
 impl<D:Decoder> Decodable<D> for WorkMap {
-    fn decode(d: &D) -> WorkMap {
+    fn decode(d: &mut D) -> WorkMap {
         let v : ~[(WorkKey,~str)] = Decodable::decode(d);
         let mut w = WorkMap::new();
         for v.each |&(k, v)| {
@@ -171,8 +169,8 @@ struct Database {
 pub impl Database {
     fn prepare(&mut self,
                fn_name: &str,
-               declared_inputs: &WorkMap) -> Option<(WorkMap, WorkMap, ~str)>
-    {
+               declared_inputs: &WorkMap)
+               -> Option<(WorkMap, WorkMap, ~str)> {
         let k = json_encode(&(fn_name, declared_inputs));
         match self.db_cache.find(&k) {
             None => None,
@@ -231,7 +229,8 @@ struct Work<T> {
 
 fn json_encode<T:Encodable<json::Encoder>>(t: &T) -> ~str {
     do io::with_str_writer |wr| {
-        t.encode(&json::Encoder(wr));
+        let mut encoder = json::Encoder(wr);
+        t.encode(&mut encoder);
     }
 }
 
@@ -239,7 +238,8 @@ fn json_encode<T:Encodable<json::Encoder>>(t: &T) -> ~str {
 fn json_decode<T:Decodable<json::Decoder>>(s: &str) -> T {
     do io::with_str_reader(s) |rdr| {
         let j = result::unwrap(json::from_reader(rdr));
-        Decodable::decode(&json::Decoder(j))
+        let mut decoder = json::Decoder(j);
+        Decodable::decode(&mut decoder)
     }
 }
 
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index ba6fe1cda4f..2216226ecb3 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -71,20 +71,21 @@ pub type Name = uint;
 pub type Mrk = uint;
 
 impl<S:Encoder> Encodable<S> for ident {
-    fn encode(&self, s: &S) {
-        let intr = match unsafe {
-            task::local_data::local_data_get(interner_key!())
-        } {
-            None => fail!(~"encode: TLS interner not set up"),
-            Some(intr) => intr
-        };
-
-        s.emit_str(*(*intr).get(*self));
+    fn encode(&self, s: &mut S) {
+        unsafe {
+            let intr =
+                match task::local_data::local_data_get(interner_key!()) {
+                    None => fail!(~"encode: TLS interner not set up"),
+                    Some(intr) => intr
+                };
+
+            s.emit_str(*(*intr).get(*self));
+        }
     }
 }
 
 impl<D:Decoder> Decodable<D> for ident {
-    fn decode(d: &D) -> ident {
+    fn decode(d: &mut D) -> ident {
         let intr = match unsafe {
             task::local_data::local_data_get(interner_key!())
         } {
@@ -389,7 +390,7 @@ pub enum binop {
     add,
     subtract,
     mul,
-    quot,
+    div,
     rem,
     and,
     or,
@@ -1158,6 +1159,7 @@ pub struct struct_field_ {
     kind: struct_field_kind,
     id: node_id,
     ty: @Ty,
+    attrs: ~[attribute],
 }
 
 pub type struct_field = spanned<struct_field_>;
@@ -1174,10 +1176,7 @@ pub enum struct_field_kind {
 #[auto_decode]
 #[deriving(Eq)]
 pub struct struct_def {
-    fields: ~[@struct_field], /* fields */
-    /* (not including ctor or dtor) */
-    /* dtor is optional */
-    dtor: Option<struct_dtor>,
+    fields: ~[@struct_field], /* fields, not including ctor */
     /* ID of the constructor. This is only used for tuple- or enum-like
      * structs. */
     ctor_id: Option<node_id>
@@ -1230,18 +1229,6 @@ impl to_bytes::IterBytes for struct_mutability {
     }
 }
 
-pub type struct_dtor = spanned<struct_dtor_>;
-
-#[auto_encode]
-#[auto_decode]
-#[deriving(Eq)]
-pub struct struct_dtor_ {
-    id: node_id,
-    attrs: ~[attribute],
-    self_id: node_id,
-    body: blk,
-}
-
 #[auto_encode]
 #[auto_decode]
 #[deriving(Eq)]
@@ -1272,7 +1259,6 @@ pub enum inlined_item {
     ii_item(@item),
     ii_method(def_id /* impl id */, @method),
     ii_foreign(@foreign_item),
-    ii_dtor(struct_dtor, ident, Generics, def_id /* parent id */)
 }
 
 /* hold off on tests ... they appear in a later merge.
@@ -1361,12 +1347,3 @@ mod test {
 }
 
 */
-//
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
-//
diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs
index eb131b17c2f..77a02adbafb 100644
--- a/src/libsyntax/ast_map.rs
+++ b/src/libsyntax/ast_map.rs
@@ -14,7 +14,6 @@ use ast;
 use ast_util::{inlined_item_utils, stmt_id};
 use ast_util;
 use codemap;
-use codemap::spanned;
 use diagnostic::span_handler;
 use parse::token::ident_interner;
 use print::pprust;
@@ -92,8 +91,6 @@ pub enum ast_node {
     node_stmt(@stmt),
     node_arg,
     node_local(ident),
-    // Destructor for a struct
-    node_dtor(Generics, @struct_dtor, def_id, @path),
     node_block(blk),
     node_struct_ctor(@struct_def, @item, @path),
     node_callee_scope(@expr)
@@ -159,7 +156,7 @@ pub fn map_decoded_item(diag: @span_handler,
     // don't decode and instantiate the impl, but just the method, we have to
     // add it to the table now:
     match *ii {
-      ii_item(*) | ii_dtor(*) => { /* fallthrough */ }
+      ii_item(*) => { /* fallthrough */ }
       ii_foreign(i) => {
         cx.map.insert(i.id, node_foreign_item(i,
                                               AbiSet::Intrinsic(),
@@ -187,27 +184,6 @@ pub fn map_fn(
     for decl.inputs.each |a| {
         cx.map.insert(a.id, node_arg);
     }
-    match *fk {
-        visit::fk_dtor(generics, ref attrs, self_id, parent_id) => {
-            let dt = @spanned {
-                node: ast::struct_dtor_ {
-                    id: id,
-                    attrs: /* FIXME (#2543) */ vec::from_slice(*attrs),
-                    self_id: self_id,
-                    body: /* FIXME (#2543) */ copy *body,
-                },
-                span: sp,
-            };
-            cx.map.insert(
-                id,
-                node_dtor(
-                    /* FIXME (#2543) */ copy *generics,
-                    dt,
-                    parent_id,
-                    @/* FIXME (#2543) */ copy cx.path));
-      }
-      _ => ()
-    }
     visit::visit_fn(fk, decl, body, sp, id, cx, v);
 }
 
@@ -410,9 +386,6 @@ pub fn node_id_to_str(map: map, id: node_id, itr: @ident_interner) -> ~str {
       Some(&node_local(ident)) => {
         fmt!("local (id=%?, name=%s)", id, *itr.get(ident))
       }
-      Some(&node_dtor(*)) => { // add more info here
-        fmt!("node_dtor (id=%?)", id)
-      }
       Some(&node_block(_)) => {
         fmt!("block")
       }
@@ -430,11 +403,3 @@ pub fn node_item_query<Result>(items: map, id: node_id,
         _ => fail!(error_msg)
     }
 }
-
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs
index 7e24adabdb0..a6094903d7b 100644
--- a/src/libsyntax/ast_util.rs
+++ b/src/libsyntax/ast_util.rs
@@ -11,7 +11,7 @@
 use ast::*;
 use ast;
 use ast_util;
-use codemap::{span, dummy_sp, spanned};
+use codemap::{span, spanned};
 use parse::token;
 use visit;
 use opt_vec;
@@ -41,12 +41,12 @@ pub fn stmt_id(s: &stmt) -> node_id {
     }
 }
 
-pub fn variant_def_ids(d: def) -> (def_id, def_id) {
+pub fn variant_def_ids(d: def) -> Option<(def_id, def_id)> {
     match d {
       def_variant(enum_id, var_id) => {
-        return (enum_id, var_id);
+          Some((enum_id, var_id))
       }
-      _ => fail!(~"non-variant in variant_def_ids")
+      _ => None
     }
 }
 
@@ -73,7 +73,7 @@ pub fn binop_to_str(op: binop) -> ~str {
       add => return ~"+",
       subtract => return ~"-",
       mul => return ~"*",
-      quot => return ~"/",
+      div => return ~"/",
       rem => return ~"%",
       and => return ~"&&",
       or => return ~"||",
@@ -96,7 +96,7 @@ pub fn binop_to_method_name(op: binop) -> Option<~str> {
       add => return Some(~"add"),
       subtract => return Some(~"sub"),
       mul => return Some(~"mul"),
-      quot => return Some(~"quot"),
+      div => return Some(~"div"),
       rem => return Some(~"rem"),
       bitxor => return Some(~"bitxor"),
       bitand => return Some(~"bitand"),
@@ -302,7 +302,6 @@ impl inlined_item_utils for inlined_item {
             ii_item(i) => /* FIXME (#2543) */ copy i.ident,
             ii_foreign(i) => /* FIXME (#2543) */ copy i.ident,
             ii_method(_, m) => /* FIXME (#2543) */ copy m.ident,
-            ii_dtor(_, nm, _, _) => /* FIXME (#2543) */ copy nm
         }
     }
 
@@ -311,7 +310,6 @@ impl inlined_item_utils for inlined_item {
             ii_item(i) => i.id,
             ii_foreign(i) => i.id,
             ii_method(_, m) => m.id,
-            ii_dtor(ref dtor, _, _, _) => (*dtor).node.id
         }
     }
 
@@ -320,10 +318,6 @@ impl inlined_item_utils for inlined_item {
             ii_item(i) => (v.visit_item)(i, e, v),
             ii_foreign(i) => (v.visit_foreign_item)(i, e, v),
             ii_method(_, m) => visit::visit_method_helper(m, e, v),
-            ii_dtor(/*bad*/ copy dtor, _, ref generics, parent_id) => {
-                visit::visit_struct_dtor_helper(dtor, generics,
-                                                parent_id, e, v);
-            }
         }
     }
 }
@@ -341,7 +335,7 @@ pub fn is_self(d: ast::def) -> bool {
 /// Maps a binary operator to its precedence
 pub fn operator_prec(op: ast::binop) -> uint {
   match op {
-      mul | quot | rem   => 12u,
+      mul | div | rem   => 12u,
       // 'as' sits between here with 11
       add | subtract    => 10u,
       shl | shr         =>  9u,
@@ -359,20 +353,6 @@ pub fn operator_prec(op: ast::binop) -> uint {
 /// not appearing in the prior table.
 pub static as_prec: uint = 11u;
 
-pub fn dtor_ty() -> @ast::Ty {
-    @ast::Ty {id: 0, node: ty_nil, span: dummy_sp()}
-}
-
-pub fn dtor_dec() -> fn_decl {
-    let nil_t = dtor_ty();
-    // dtor has no args
-    ast::fn_decl {
-        inputs: ~[],
-        output: nil_t,
-        cf: return_val,
-    }
-}
-
 pub fn empty_generics() -> Generics {
     Generics {lifetimes: opt_vec::Empty,
               ty_params: opt_vec::Empty}
@@ -469,12 +449,6 @@ pub fn id_visitor(vfn: @fn(node_id)) -> visit::vt<()> {
             vfn(id);
 
             match *fk {
-                visit::fk_dtor(generics, _, self_id, parent_id) => {
-                    visit_generics(generics);
-                    vfn(id);
-                    vfn(self_id);
-                    vfn(parent_id.node);
-                }
                 visit::fk_item_fn(_, generics, _, _) => {
                     visit_generics(generics);
                 }
@@ -868,11 +842,3 @@ mod test {
     }
 
 }
-
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs
index 2f8405c6e96..f4f0def2843 100644
--- a/src/libsyntax/attr.rs
+++ b/src/libsyntax/attr.rs
@@ -341,13 +341,3 @@ pub fn require_unique_names(diagnostic: @span_handler,
         }
     }
 }
-
-//
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
-//
diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs
index 1c822b520f6..846097550d1 100644
--- a/src/libsyntax/codemap.rs
+++ b/src/libsyntax/codemap.rs
@@ -127,11 +127,13 @@ impl cmp::Eq for span {
 
 impl<S:Encoder> Encodable<S> for span {
     /* Note #1972 -- spans are encoded but not decoded */
-    fn encode(&self, _s: &S) { _s.emit_nil() }
+    fn encode(&self, s: &mut S) {
+        s.emit_nil()
+    }
 }
 
 impl<D:Decoder> Decodable<D> for span {
-    fn decode(_d: &D) -> span {
+    fn decode(_d: &mut D) -> span {
         dummy_sp()
     }
 }
@@ -522,15 +524,3 @@ mod test {
         fm.next_line(BytePos(2));
     }
 }
-
-
-
-//
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
-//
diff --git a/src/libsyntax/ext/asm.rs b/src/libsyntax/ext/asm.rs
index dfebf6f786a..53f40113532 100644
--- a/src/libsyntax/ext/asm.rs
+++ b/src/libsyntax/ext/asm.rs
@@ -187,15 +187,3 @@ pub fn expand_asm(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree])
         span: sp
     })
 }
-
-
-
-//
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
-//
diff --git a/src/libsyntax/ext/auto_encode.rs b/src/libsyntax/ext/auto_encode.rs
index 2ceb6f0c4bb..bdf0a2a1dd0 100644
--- a/src/libsyntax/ext/auto_encode.rs
+++ b/src/libsyntax/ext/auto_encode.rs
@@ -238,7 +238,8 @@ trait ExtCtxtMethods {
     fn stmt(&self, expr: @ast::expr) -> @ast::stmt;
     fn lit_str(&self, span: span, s: @~str) -> @ast::expr;
     fn lit_uint(&self, span: span, i: uint) -> @ast::expr;
-    fn lambda(&self, blk: ast::blk) -> @ast::expr;
+    fn lambda0(&self, blk: ast::blk) -> @ast::expr;
+    fn lambda1(&self, blk: ast::blk, ident: ast::ident) -> @ast::expr;
     fn blk(&self, span: span, stmts: ~[@ast::stmt]) -> ast::blk;
     fn expr_blk(&self, expr: @ast::expr) -> ast::blk;
     fn expr_path(&self, span: span, strs: ~[ast::ident]) -> @ast::expr;
@@ -254,8 +255,15 @@ trait ExtCtxtMethods {
                         ident: ast::ident,
                         args: ~[@ast::expr])
                         -> @ast::expr;
-    fn lambda_expr(&self, expr: @ast::expr) -> @ast::expr;
-    fn lambda_stmts(&self, span: span, stmts: ~[@ast::stmt]) -> @ast::expr;
+    fn lambda_expr_0(&self, expr: @ast::expr) -> @ast::expr;
+    fn lambda_expr_1(&self, expr: @ast::expr, ident: ast::ident)
+                    -> @ast::expr;
+    fn lambda_stmts_0(&self, span: span, stmts: ~[@ast::stmt]) -> @ast::expr;
+    fn lambda_stmts_1(&self,
+                      span: span,
+                      stmts: ~[@ast::stmt],
+                      ident: ast::ident)
+                      -> @ast::expr;
 }
 
 impl ExtCtxtMethods for @ext_ctxt {
@@ -388,12 +396,18 @@ impl ExtCtxtMethods for @ext_ctxt {
                                 span: span}))
     }
 
-    fn lambda(&self, blk: ast::blk) -> @ast::expr {
+    fn lambda0(&self, blk: ast::blk) -> @ast::expr {
         let ext_cx = *self;
         let blk_e = self.expr(copy blk.span, ast::expr_block(copy blk));
         quote_expr!( || $blk_e )
     }
 
+    fn lambda1(&self, blk: ast::blk, ident: ast::ident) -> @ast::expr {
+        let ext_cx = *self;
+        let blk_e = self.expr(copy blk.span, ast::expr_block(copy blk));
+        quote_expr!( |$ident| $blk_e )
+    }
+
     fn blk(&self, span: span, stmts: ~[@ast::stmt]) -> ast::blk {
         codemap::spanned {
             node: ast::blk_ {
@@ -461,15 +475,29 @@ impl ExtCtxtMethods for @ext_ctxt {
         ident: ast::ident,
         args: ~[@ast::expr]
     ) -> @ast::expr {
-        self.expr(span, ast::expr_method_call(expr, ident, ~[], args, ast::NoSugar))
+        self.expr(span,
+                  ast::expr_method_call(expr, ident, ~[], args, ast::NoSugar))
+    }
+
+    fn lambda_expr_0(&self, expr: @ast::expr) -> @ast::expr {
+        self.lambda0(self.expr_blk(expr))
+    }
+
+    fn lambda_expr_1(&self, expr: @ast::expr, ident: ast::ident)
+                    -> @ast::expr {
+        self.lambda1(self.expr_blk(expr), ident)
     }
 
-    fn lambda_expr(&self, expr: @ast::expr) -> @ast::expr {
-        self.lambda(self.expr_blk(expr))
+    fn lambda_stmts_0(&self, span: span, stmts: ~[@ast::stmt]) -> @ast::expr {
+        self.lambda0(self.blk(span, stmts))
     }
 
-    fn lambda_stmts(&self, span: span, stmts: ~[@ast::stmt]) -> @ast::expr {
-        self.lambda(self.blk(span, stmts))
+    fn lambda_stmts_1(&self,
+                      span: span,
+                      stmts: ~[@ast::stmt],
+                      ident: ast::ident)
+                      -> @ast::expr {
+        self.lambda1(self.blk(span, stmts), ident)
     }
 }
 
@@ -644,7 +672,7 @@ fn mk_ser_method(
             None,
             ast::mt {
                 ty: cx.ty_path(span, ~[cx.ident_of(~"__S")], ~[]),
-                mutbl: ast::m_imm
+                mutbl: ast::m_mutbl
             }
         ),
         span: span,
@@ -706,7 +734,7 @@ fn mk_deser_method(
             None,
             ast::mt {
                 ty: cx.ty_path(span, ~[cx.ident_of(~"__D")], ~[]),
-                mutbl: ast::m_imm
+                mutbl: ast::m_mutbl
             }
         ),
         span: span,
@@ -758,8 +786,8 @@ fn mk_struct_ser_impl(
     generics: &ast::Generics
 ) -> @ast::item {
     let fields = do mk_struct_fields(fields).mapi |idx, field| {
-        // ast for `|| self.$(name).encode(__s)`
-        let expr_lambda = cx.lambda_expr(
+        // ast for `|__s| self.$(name).encode(__s)`
+        let expr_lambda = cx.lambda_expr_1(
             cx.expr_method_call(
                 span,
                 cx.expr_field(
@@ -769,7 +797,8 @@ fn mk_struct_ser_impl(
                 ),
                 cx.ident_of(~"encode"),
                 ~[cx.expr_var(span, ~"__s")]
-            )
+            ),
+            cx.ident_of(~"__s")
         );
 
         // ast for `__s.emit_struct_field($(name), $(idx), $(expr_lambda))`
@@ -787,7 +816,7 @@ fn mk_struct_ser_impl(
         )
     };
 
-    // ast for `__s.emit_struct($(name), || $(fields))`
+    // ast for `__s.emit_struct($(name), |__s| $(fields))`
     let ser_body = cx.expr_method_call(
         span,
         cx.expr_var(span, ~"__s"),
@@ -795,7 +824,7 @@ fn mk_struct_ser_impl(
         ~[
             cx.lit_str(span, @cx.str_of(ident)),
             cx.lit_uint(span, vec::len(fields)),
-            cx.lambda_stmts(span, fields),
+            cx.lambda_stmts_1(span, fields, cx.ident_of(~"__s")),
         ]
     );
 
@@ -810,8 +839,8 @@ fn mk_struct_deser_impl(
     generics: &ast::Generics
 ) -> @ast::item {
     let fields = do mk_struct_fields(fields).mapi |idx, field| {
-        // ast for `|| std::serialize::decode(__d)`
-        let expr_lambda = cx.lambda(
+        // ast for `|__d| std::serialize::decode(__d)`
+        let expr_lambda = cx.lambda1(
             cx.expr_blk(
                 cx.expr_call(
                     span,
@@ -823,7 +852,8 @@ fn mk_struct_deser_impl(
                     ]),
                     ~[cx.expr_var(span, ~"__d")]
                 )
-            )
+            ),
+            cx.ident_of(~"__d")
         );
 
         // ast for `__d.read_struct_field($(name), $(idx), $(expr_lambda))`
@@ -848,7 +878,7 @@ fn mk_struct_deser_impl(
         }
     };
 
-    // ast for `read_struct($(name), || $(fields))`
+    // ast for `read_struct($(name), |__d| $(fields))`
     let body = cx.expr_method_call(
         span,
         cx.expr_var(span, ~"__d"),
@@ -856,7 +886,7 @@ fn mk_struct_deser_impl(
         ~[
             cx.lit_str(span, @cx.str_of(ident)),
             cx.lit_uint(span, vec::len(fields)),
-            cx.lambda_expr(
+            cx.lambda_expr_1(
                 cx.expr(
                     span,
                     ast::expr_struct(
@@ -864,7 +894,8 @@ fn mk_struct_deser_impl(
                         fields,
                         None
                     )
-                )
+                ),
+                cx.ident_of(~"__d")
             ),
         ]
     );
@@ -974,14 +1005,15 @@ fn ser_variant(
             cx.ident_of(~"emit_enum_variant_arg")
         );
 
-        // ast for `|| $(v).encode(__s)`
-        let expr_encode = cx.lambda_expr(
-             cx.expr_method_call(
+        // ast for `|__s| $(v).encode(__s)`
+        let expr_encode = cx.lambda_expr_1(
+            cx.expr_method_call(
                 span,
                  cx.expr_path(span, ~[names[a_idx]]),
                  cx.ident_of(~"encode"),
                 ~[cx.expr_var(span, ~"__s")]
-            )
+            ),
+            cx.ident_of(~"__s")
         );
 
         // ast for `$(expr_emit)($(a_idx), $(expr_encode))`
@@ -1003,7 +1035,7 @@ fn ser_variant(
             cx.lit_str(span, @cx.str_of(v_name)),
             cx.lit_uint(span, v_idx),
             cx.lit_uint(span, stmts.len()),
-            cx.lambda_stmts(span, stmts),
+            cx.lambda_stmts_1(span, stmts, cx.ident_of(~"__s")),
         ]
     );
 
@@ -1050,7 +1082,7 @@ fn mk_enum_ser_body(
         cx.ident_of(~"emit_enum"),
         ~[
             cx.lit_str(span, @cx.str_of(name)),
-            cx.lambda_expr(match_expr),
+            cx.lambda_expr_1(match_expr, cx.ident_of(~"__s")),
         ]
     )
 }
@@ -1062,8 +1094,8 @@ fn mk_enum_deser_variant_nary(
     args: ~[ast::variant_arg]
 ) -> @ast::expr {
     let args = do args.mapi |idx, _arg| {
-        // ast for `|| std::serialize::decode(__d)`
-        let expr_lambda = cx.lambda_expr(
+        // ast for `|__s| std::serialize::decode(__d)`
+        let expr_lambda = cx.lambda_expr_1(
             cx.expr_call(
                 span,
                 cx.expr_path_global(span, ~[
@@ -1073,7 +1105,8 @@ fn mk_enum_deser_variant_nary(
                     cx.ident_of(~"decode"),
                 ]),
                 ~[cx.expr_var(span, ~"__d")]
-            )
+            ),
+            cx.ident_of(~"__d")
         );
 
         // ast for `__d.read_enum_variant_arg($(a_idx), $(expr_lambda))`
@@ -1163,24 +1196,44 @@ fn mk_enum_deser_body(
         span,
         ast::expr_fn_block(
             ast::fn_decl {
-                inputs: ~[ast::arg {
-                    is_mutbl: false,
-                    ty: @ast::Ty {
+                inputs: ~[
+                    ast::arg {
+                        is_mutbl: false,
+                        ty: @ast::Ty {
+                            id: ext_cx.next_id(),
+                            node: ast::ty_infer,
+                            span: span
+                        },
+                        pat: @ast::pat {
+                            id: ext_cx.next_id(),
+                            node: ast::pat_ident(
+                                ast::bind_by_copy,
+                                ast_util::ident_to_path(span,
+                                    ext_cx.ident_of(~"__d")),
+                                None),
+                            span: span,
+                        },
                         id: ext_cx.next_id(),
-                        node: ast::ty_infer,
-                        span: span
                     },
-                    pat: @ast::pat {
+                    ast::arg {
+                        is_mutbl: false,
+                        ty: @ast::Ty {
+                            id: ext_cx.next_id(),
+                            node: ast::ty_infer,
+                            span: span
+                        },
+                        pat: @ast::pat {
+                            id: ext_cx.next_id(),
+                            node: ast::pat_ident(
+                                ast::bind_by_copy,
+                                ast_util::ident_to_path(span,
+                                    ext_cx.ident_of(~"i")),
+                                None),
+                            span: span,
+                        },
                         id: ext_cx.next_id(),
-                        node: ast::pat_ident(
-                            ast::bind_by_copy,
-                            ast_util::ident_to_path(span,
-                                ext_cx.ident_of(~"i")),
-                            None),
-                        span: span,
-                    },
-                    id: ext_cx.next_id(),
-                }],
+                    }
+                ],
                 output: @ast::Ty {
                     id: ext_cx.next_id(),
                     node: ast::ty_infer,
@@ -1198,13 +1251,14 @@ fn mk_enum_deser_body(
     );
 
     // ast for `__d.read_enum_variant($expr_arm_names, $(expr_lambda))`
-    let expr_lambda = ext_cx.lambda_expr(
+    let expr_lambda = ext_cx.lambda_expr_1(
         ext_cx.expr_method_call(
             span,
             ext_cx.expr_var(span, ~"__d"),
             ext_cx.ident_of(~"read_enum_variant"),
             ~[expr_arm_names, expr_lambda]
-        )
+        ),
+        ext_cx.ident_of(~"__d")
     );
 
     // ast for `__d.read_enum($(e_name), $(expr_lambda))`
@@ -1256,105 +1310,147 @@ mod test {
     }
 
     impl Encoder for TestEncoder {
-        fn emit_nil(&self) { self.add_to_log(CallToEmitNil) }
+        fn emit_nil(&mut self) { self.add_to_log(CallToEmitNil) }
 
-        fn emit_uint(&self, v: uint) {self.add_to_log(CallToEmitUint(v)); }
-        fn emit_u64(&self, _v: u64) { self.add_unknown_to_log(); }
-        fn emit_u32(&self, _v: u32) { self.add_unknown_to_log(); }
-        fn emit_u16(&self, _v: u16) { self.add_unknown_to_log(); }
-        fn emit_u8(&self, _v: u8)   { self.add_unknown_to_log(); }
+        fn emit_uint(&mut self, v: uint) {
+            self.add_to_log(CallToEmitUint(v));
+        }
+        fn emit_u64(&mut self, _v: u64) { self.add_unknown_to_log(); }
+        fn emit_u32(&mut self, _v: u32) { self.add_unknown_to_log(); }
+        fn emit_u16(&mut self, _v: u16) { self.add_unknown_to_log(); }
+        fn emit_u8(&mut self, _v: u8)   { self.add_unknown_to_log(); }
 
-        fn emit_int(&self, _v: int) { self.add_unknown_to_log(); }
-        fn emit_i64(&self, _v: i64) { self.add_unknown_to_log(); }
-        fn emit_i32(&self, _v: i32) { self.add_unknown_to_log(); }
-        fn emit_i16(&self, _v: i16) { self.add_unknown_to_log(); }
-        fn emit_i8(&self, _v: i8)   { self.add_unknown_to_log(); }
+        fn emit_int(&mut self, _v: int) { self.add_unknown_to_log(); }
+        fn emit_i64(&mut self, _v: i64) { self.add_unknown_to_log(); }
+        fn emit_i32(&mut self, _v: i32) { self.add_unknown_to_log(); }
+        fn emit_i16(&mut self, _v: i16) { self.add_unknown_to_log(); }
+        fn emit_i8(&mut self, _v: i8)   { self.add_unknown_to_log(); }
 
-        fn emit_bool(&self, _v: bool) { self.add_unknown_to_log(); }
+        fn emit_bool(&mut self, _v: bool) { self.add_unknown_to_log(); }
 
-        fn emit_f64(&self, _v: f64) { self.add_unknown_to_log(); }
-        fn emit_f32(&self, _v: f32) { self.add_unknown_to_log(); }
-        fn emit_float(&self, _v: float) { self.add_unknown_to_log(); }
+        fn emit_f64(&mut self, _v: f64) { self.add_unknown_to_log(); }
+        fn emit_f32(&mut self, _v: f32) { self.add_unknown_to_log(); }
+        fn emit_float(&mut self, _v: float) { self.add_unknown_to_log(); }
 
-        fn emit_char(&self, _v: char) { self.add_unknown_to_log(); }
-        fn emit_str(&self, _v: &str) { self.add_unknown_to_log(); }
+        fn emit_char(&mut self, _v: char) { self.add_unknown_to_log(); }
+        fn emit_str(&mut self, _v: &str) { self.add_unknown_to_log(); }
 
-        fn emit_enum(&self, name: &str, f: &fn()) {
-            self.add_to_log(CallToEmitEnum(name.to_str())); f(); }
+        fn emit_enum(&mut self, name: &str, f: &fn(&mut TestEncoder)) {
+            self.add_to_log(CallToEmitEnum(name.to_str()));
+            f(self);
+        }
 
-        fn emit_enum_variant(&self, name: &str, id: uint,
-                             cnt: uint, f: &fn()) {
-            self.add_to_log(CallToEmitEnumVariant (name.to_str(),id,cnt));
-            f();
+        fn emit_enum_variant(&mut self,
+                             name: &str,
+                             id: uint,
+                             cnt: uint,
+                             f: &fn(&mut TestEncoder)) {
+            self.add_to_log(CallToEmitEnumVariant(name.to_str(), id, cnt));
+            f(self);
         }
 
-        fn emit_enum_variant_arg(&self, idx: uint, f: &fn()) {
-            self.add_to_log(CallToEmitEnumVariantArg (idx)); f();
+        fn emit_enum_variant_arg(&mut self,
+                                 idx: uint,
+                                 f: &fn(&mut TestEncoder)) {
+            self.add_to_log(CallToEmitEnumVariantArg(idx));
+            f(self);
         }
 
-        fn emit_enum_struct_variant(&self, name: &str, id: uint, cnt: uint, f: &fn()) {
+        fn emit_enum_struct_variant(&mut self,
+                                    name: &str,
+                                    id: uint,
+                                    cnt: uint,
+                                    f: &fn(&mut TestEncoder)) {
             self.emit_enum_variant(name, id, cnt, f)
         }
 
-        fn emit_enum_struct_variant_field(&self, _name: &str, idx: uint, f: &fn()) {
+        fn emit_enum_struct_variant_field(&mut self,
+                                          _name: &str,
+                                          idx: uint,
+                                          f: &fn(&mut TestEncoder)) {
             self.emit_enum_variant_arg(idx, f)
         }
 
-        fn emit_struct(&self, name: &str, len: uint, f: &fn()) {
-            self.add_to_log(CallToEmitStruct (name.to_str(),len)); f();
+        fn emit_struct(&mut self,
+                       name: &str,
+                       len: uint,
+                       f: &fn(&mut TestEncoder)) {
+            self.add_to_log(CallToEmitStruct (name.to_str(),len));
+            f(self);
         }
-        fn emit_struct_field(&self, name: &str, idx: uint, f: &fn()) {
-            self.add_to_log(CallToEmitField (name.to_str(),idx)); f();
+        fn emit_struct_field(&mut self,
+                             name: &str,
+                             idx: uint,
+                             f: &fn(&mut TestEncoder)) {
+            self.add_to_log(CallToEmitField (name.to_str(),idx));
+            f(self);
         }
 
-        fn emit_tuple(&self, _len: uint, f: &fn()) {
-            self.add_unknown_to_log(); f();
+        fn emit_tuple(&mut self, _len: uint, f: &fn(&mut TestEncoder)) {
+            self.add_unknown_to_log();
+            f(self);
         }
-        fn emit_tuple_arg(&self, _idx: uint, f: &fn()) {
-            self.add_unknown_to_log(); f();
+        fn emit_tuple_arg(&mut self, _idx: uint, f: &fn(&mut TestEncoder)) {
+            self.add_unknown_to_log();
+            f(self);
         }
 
-        fn emit_tuple_struct(&self, _name: &str, _len: uint, f: &fn()) {
-            self.add_unknown_to_log(); f();
+        fn emit_tuple_struct(&mut self,
+                             _name: &str,
+                             _len: uint,
+                             f: &fn(&mut TestEncoder)) {
+            self.add_unknown_to_log();
+            f(self);
         }
-        fn emit_tuple_struct_arg(&self, _idx: uint, f: &fn()) {
-            self.add_unknown_to_log(); f();
+
+        fn emit_tuple_struct_arg(&mut self,
+                                 _idx: uint,
+                                 f: &fn(&mut TestEncoder)) {
+            self.add_unknown_to_log();
+            f(self);
         }
 
-        fn emit_option(&self, f: &fn()) {
+        fn emit_option(&mut self, f: &fn(&mut TestEncoder)) {
             self.add_to_log(CallToEmitOption);
-            f();
+            f(self);
         }
-        fn emit_option_none(&self) {
+        fn emit_option_none(&mut self) {
             self.add_to_log(CallToEmitOptionNone);
         }
-        fn emit_option_some(&self, f: &fn()) {
+        fn emit_option_some(&mut self, f: &fn(&mut TestEncoder)) {
             self.add_to_log(CallToEmitOptionSome);
-            f();
+            f(self);
         }
 
-        fn emit_seq(&self, _len: uint, f: &fn()) {
-            self.add_unknown_to_log(); f();
+        fn emit_seq(&mut self, _len: uint, f: &fn(&mut TestEncoder)) {
+            self.add_unknown_to_log();
+            f(self);
         }
-        fn emit_seq_elt(&self, _idx: uint, f: &fn()) {
-            self.add_unknown_to_log(); f();
+        fn emit_seq_elt(&mut self, _idx: uint, f: &fn(&mut TestEncoder)) {
+            self.add_unknown_to_log();
+            f(self);
         }
 
-        fn emit_map(&self, _len: uint, f: &fn()) {
-            self.add_unknown_to_log(); f();
+        fn emit_map(&mut self, _len: uint, f: &fn(&mut TestEncoder)) {
+            self.add_unknown_to_log();
+            f(self);
         }
-        fn emit_map_elt_key(&self, _idx: uint, f: &fn()) {
-            self.add_unknown_to_log(); f();
+        fn emit_map_elt_key(&mut self, _idx: uint, f: &fn(&mut TestEncoder)) {
+            self.add_unknown_to_log();
+            f(self);
         }
-        fn emit_map_elt_val(&self, _idx: uint, f: &fn()) {
-            self.add_unknown_to_log(); f();
+        fn emit_map_elt_val(&mut self, _idx: uint, f: &fn(&mut TestEncoder)) {
+            self.add_unknown_to_log();
+            f(self);
         }
     }
 
 
     fn to_call_log<E:Encodable<TestEncoder>>(val: E) -> ~[call] {
-        let mut te = TestEncoder {call_log: @mut ~[]};
-        val.encode(&te);
+        let mut te = TestEncoder {
+            call_log: @mut ~[]
+        };
+        val.encode(&mut te);
         copy *te.call_log
     }
 
diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs
index 7d058f22e4c..da8f87d3891 100644
--- a/src/libsyntax/ext/base.rs
+++ b/src/libsyntax/ext/base.rs
@@ -348,7 +348,7 @@ pub fn expr_to_str(cx: @ext_ctxt, expr: @ast::expr, err_msg: ~str) -> ~str {
 
 pub fn expr_to_ident(cx: @ext_ctxt,
                      expr: @ast::expr,
-                     err_msg: ~str) -> ast::ident {
+                     err_msg: &str) -> ast::ident {
     match expr.node {
       ast::expr_path(p) => {
         if vec::len(p.types) > 0u || vec::len(p.idents) != 1u {
@@ -538,13 +538,3 @@ mod test {
         assert_eq!(*(m.find(&@~"def").get()),16);
     }
 }
-
-//
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
-//
diff --git a/src/libsyntax/ext/deriving/decodable.rs b/src/libsyntax/ext/deriving/decodable.rs
index 48f6d5baa8b..fe270abc2e4 100644
--- a/src/libsyntax/ext/deriving/decodable.rs
+++ b/src/libsyntax/ext/deriving/decodable.rs
@@ -96,7 +96,7 @@ fn create_decode_method(
         cx,
         span,
         build::mk_simple_ty_path(cx, span, cx.ident_of(~"__D")),
-        ast::m_imm
+        ast::m_mutbl
     );
     let d_ident = cx.ident_of(~"__d");
     let d_arg = build::mk_arg(cx, span, d_ident, d_arg_type);
@@ -219,6 +219,11 @@ fn create_read_struct_field(
     // Call the substructure method.
     let decode_expr = call_substructure_decode_method(cx, span);
 
+    let d_arg = build::mk_arg(cx,
+                              span,
+                              cx.ident_of(~"__d"),
+                              build::mk_ty_infer(cx, span));
+
     let call_expr = build::mk_method_call(
         cx,
         span,
@@ -227,7 +232,11 @@ fn create_read_struct_field(
         ~[
             build::mk_base_str(cx, span, cx.str_of(ident)),
             build::mk_uint(cx, span, idx),
-            build::mk_lambda_no_args(cx, span, decode_expr),
+            build::mk_lambda(cx,
+                             span,
+                             build::mk_fn_decl(~[d_arg],
+                                               build::mk_ty_infer(cx, span)),
+                             decode_expr),
         ]
     );
 
@@ -282,6 +291,11 @@ fn expand_deriving_decodable_struct_method(
         i += 1;
     }
 
+    let d_arg = build::mk_arg(cx,
+                              span,
+                              cx.ident_of(~"__d"),
+                              build::mk_ty_infer(cx, span));
+
     let read_struct_expr = build::mk_method_call(
         cx,
         span,
@@ -294,9 +308,10 @@ fn expand_deriving_decodable_struct_method(
         ~[
             build::mk_base_str(cx, span, cx.str_of(type_ident)),
             build::mk_uint(cx, span, fields.len()),
-            build::mk_lambda_no_args(
+            build::mk_lambda(
                 cx,
                 span,
+                build::mk_fn_decl(~[d_arg], build::mk_ty_infer(cx, span)),
                 build::mk_struct_e(
                     cx,
                     span,
@@ -334,6 +349,12 @@ fn create_read_variant_arg(
             // Call the substructure method.
             let expr = call_substructure_decode_method(cx, span);
 
+            let d_arg = build::mk_arg(cx,
+                                      span,
+                                      cx.ident_of(~"__d"),
+                                      build::mk_ty_infer(cx, span));
+            let t_infer = build::mk_ty_infer(cx, span);
+
             let call_expr = build::mk_method_call(
                 cx,
                 span,
@@ -341,7 +362,10 @@ fn create_read_variant_arg(
                 cx.ident_of(~"read_enum_variant_arg"),
                 ~[
                     build::mk_uint(cx, span, j),
-                    build::mk_lambda_no_args(cx, span, expr),
+                    build::mk_lambda(cx,
+                                     span,
+                                     build::mk_fn_decl(~[d_arg], t_infer),
+                                     expr),
                 ]
             );
 
@@ -402,6 +426,12 @@ fn create_read_enum_variant(
                         build::mk_arg(
                             cx,
                             span,
+                            cx.ident_of(~"__d"),
+                            build::mk_ty_infer(cx, span)
+                        ),
+                        build::mk_arg(
+                            cx,
+                            span,
                             cx.ident_of(~"__i"),
                             build::mk_ty_infer(cx, span)
                         )
@@ -434,6 +464,11 @@ fn expand_deriving_decodable_enum_method(
         enum_definition
     );
 
+    let d_arg = build::mk_arg(cx,
+                              span,
+                              cx.ident_of(~"__d"),
+                              build::mk_ty_infer(cx, span));
+
     // Create the read_enum expression
     let read_enum_expr = build::mk_method_call(
         cx,
@@ -442,7 +477,11 @@ fn expand_deriving_decodable_enum_method(
         cx.ident_of(~"read_enum"),
         ~[
             build::mk_base_str(cx, span, cx.str_of(type_ident)),
-            build::mk_lambda_no_args(cx, span, read_enum_variant_expr),
+            build::mk_lambda(cx,
+                             span,
+                             build::mk_fn_decl(~[d_arg],
+                                               build::mk_ty_infer(cx, span)),
+                             read_enum_variant_expr),
         ]
     );
 
diff --git a/src/libsyntax/ext/deriving/encodable.rs b/src/libsyntax/ext/deriving/encodable.rs
index 640d0d0ff2d..8f8139790ad 100644
--- a/src/libsyntax/ext/deriving/encodable.rs
+++ b/src/libsyntax/ext/deriving/encodable.rs
@@ -94,10 +94,9 @@ fn create_encode_method(
         cx,
         span,
         build::mk_simple_ty_path(cx, span, cx.ident_of(~"__E")),
-        ast::m_imm
+        ast::m_mutbl
     );
-    let e_ident = cx.ident_of(~"__e");
-    let e_arg = build::mk_arg(cx, span, e_ident, e_arg_type);
+    let e_arg = build::mk_arg(cx, span, cx.ident_of(~"__e"), e_arg_type);
 
     // Create the type of the return value.
     let output_type = @ast::Ty { id: cx.next_id(), node: ty_nil, span: span };
@@ -226,10 +225,16 @@ fn expand_deriving_encodable_struct_method(
                     self_field
                 );
 
+                let e_ident = cx.ident_of(~"__e");
+                let e_arg = build::mk_arg(cx,
+                                          span,
+                                          e_ident,
+                                          build::mk_ty_infer(cx, span));
+
                 let blk_expr = build::mk_lambda(
                     cx,
                     span,
-                    build::mk_fn_decl(~[], build::mk_ty_infer(cx, span)),
+                    build::mk_fn_decl(~[e_arg], build::mk_ty_infer(cx, span)),
                     encode_expr
                 );
 
@@ -257,6 +262,11 @@ fn expand_deriving_encodable_struct_method(
         idx += 1;
     }
 
+    let e_arg = build::mk_arg(cx,
+                              span,
+                              cx.ident_of(~"__e"),
+                              build::mk_ty_infer(cx, span));
+
     let emit_struct_stmt = build::mk_method_call(
         cx,
         span,
@@ -272,7 +282,7 @@ fn expand_deriving_encodable_struct_method(
             build::mk_lambda_stmts(
                 cx,
                 span,
-                build::mk_fn_decl(~[], build::mk_ty_infer(cx, span)),
+                build::mk_fn_decl(~[e_arg], build::mk_ty_infer(cx, span)),
                 statements
             ),
         ]
@@ -309,10 +319,16 @@ fn expand_deriving_encodable_enum_method(
             // Call the substructure method.
             let expr = call_substructure_encode_method(cx, span, field);
 
+            let e_ident = cx.ident_of(~"__e");
+            let e_arg = build::mk_arg(cx,
+                                      span,
+                                      e_ident,
+                                      build::mk_ty_infer(cx, span));
+
             let blk_expr = build::mk_lambda(
                 cx,
                 span,
-                build::mk_fn_decl(~[], build::mk_ty_infer(cx, span)),
+                build::mk_fn_decl(~[e_arg], build::mk_ty_infer(cx, span)),
                 expr
             );
 
@@ -331,6 +347,10 @@ fn expand_deriving_encodable_enum_method(
         }
 
         // Create the pattern body.
+        let e_arg = build::mk_arg(cx,
+                                  span,
+                                  cx.ident_of(~"__e"),
+                                  build::mk_ty_infer(cx, span));
         let call_expr = build::mk_method_call(
             cx,
             span,
@@ -343,7 +363,7 @@ fn expand_deriving_encodable_enum_method(
                 build::mk_lambda_stmts(
                     cx,
                     span,
-                    build::mk_fn_decl(~[], build::mk_ty_infer(cx, span)),
+                    build::mk_fn_decl(~[e_arg], build::mk_ty_infer(cx, span)),
                     stmts
                 )
             ]
@@ -359,11 +379,17 @@ fn expand_deriving_encodable_enum_method(
         }
     };
 
+    let e_ident = cx.ident_of(~"__e");
+    let e_arg = build::mk_arg(cx,
+                              span,
+                              e_ident,
+                              build::mk_ty_infer(cx, span));
+
     // Create the method body.
     let lambda_expr = build::mk_lambda(
         cx,
         span,
-        build::mk_fn_decl(~[], build::mk_ty_infer(cx, span)),
+        build::mk_fn_decl(~[e_arg], build::mk_ty_infer(cx, span)),
         expand_enum_or_struct_match(cx, span, arms)
     );
 
diff --git a/src/libsyntax/ext/env.rs b/src/libsyntax/ext/env.rs
index 5e5fd7d97b1..5b1e3737b23 100644
--- a/src/libsyntax/ext/env.rs
+++ b/src/libsyntax/ext/env.rs
@@ -34,13 +34,3 @@ pub fn expand_syntax_ext(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree])
     };
     MRExpr(e)
 }
-
-//
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
-//
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs
index 841f64e0b05..965d95789c4 100644
--- a/src/libsyntax/ext/expand.rs
+++ b/src/libsyntax/ext/expand.rs
@@ -490,7 +490,7 @@ pub fn core_macros() -> ~str {
 
         { $c:ident: $in:ty -> $out:ty; } => {
 
-            mod $c {
+            pub mod $c {
                 fn key(_x: @::core::condition::Handler<$in,$out>) { }
 
                 pub static cond :
@@ -724,11 +724,3 @@ mod test {
     }
 
 }
-
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
diff --git a/src/libsyntax/ext/fmt.rs b/src/libsyntax/ext/fmt.rs
index 9bbe617eb07..e9eebe5b2ac 100644
--- a/src/libsyntax/ext/fmt.rs
+++ b/src/libsyntax/ext/fmt.rs
@@ -273,15 +273,13 @@ fn pieces_to_expr(cx: @ext_ctxt, sp: span,
         match pc {
             /* Raw strings get appended via str::push_str */
             PieceString(s) => {
-                let portion = mk_uniq_str(cx, fmt_sp, s);
-
                 /* If this is the first portion, then initialize the local
                    buffer with it directly. If it's actually the only piece,
                    then there's no need for it to be mutable */
                 if i == 0 {
-                    stms.push(mk_local(cx, fmt_sp, npieces > 1, ident, portion));
+                    stms.push(mk_local(cx, fmt_sp, npieces > 1, ident, mk_uniq_str(cx, fmt_sp, s)));
                 } else {
-                    let args = ~[mk_mut_addr_of(cx, fmt_sp, buf()), portion];
+                    let args = ~[mk_mut_addr_of(cx, fmt_sp, buf()), mk_base_str(cx, fmt_sp, s)];
                     let call = mk_call_global(cx,
                                               fmt_sp,
                                               ~[str_ident, push_ident],
@@ -322,12 +320,3 @@ fn pieces_to_expr(cx: @ext_ctxt, sp: span,
 
     return mk_block(cx, fmt_sp, ~[], stms, Some(buf()));
 }
-//
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
-//
diff --git a/src/libsyntax/ext/pipes/check.rs b/src/libsyntax/ext/pipes/check.rs
index c2c0c06342b..38e43d1ade5 100644
--- a/src/libsyntax/ext/pipes/check.rs
+++ b/src/libsyntax/ext/pipes/check.rs
@@ -80,4 +80,3 @@ impl proto::visitor<(), (), ()> for @ext_ctxt {
         }
     }
 }
-
diff --git a/src/libsyntax/ext/pipes/liveness.rs b/src/libsyntax/ext/pipes/liveness.rs
index 7843db55789..bd5353b2100 100644
--- a/src/libsyntax/ext/pipes/liveness.rs
+++ b/src/libsyntax/ext/pipes/liveness.rs
@@ -104,4 +104,3 @@ pub fn analyze(proto: &mut protocol_, _cx: @ext_ctxt) {
         proto.bounded = Some(true);
     }
 }
-
diff --git a/src/libsyntax/ext/pipes/mod.rs b/src/libsyntax/ext/pipes/mod.rs
index 81b2442ea82..85c578bc2ce 100644
--- a/src/libsyntax/ext/pipes/mod.rs
+++ b/src/libsyntax/ext/pipes/mod.rs
@@ -85,4 +85,3 @@ pub fn expand_proto(cx: @ext_ctxt, _sp: span, id: ast::ident,
     // compile
     base::MRItem(proto.compile(cx))
 }
-
diff --git a/src/libsyntax/ext/pipes/pipec.rs b/src/libsyntax/ext/pipes/pipec.rs
index 3311c61de8b..e876972fe68 100644
--- a/src/libsyntax/ext/pipes/pipec.rs
+++ b/src/libsyntax/ext/pipes/pipec.rs
@@ -415,7 +415,8 @@ impl gen_init for protocol {
                             ast::struct_immutable,
                             ast::inherited),
                     id: cx.next_id(),
-                    ty: fty
+                    ty: fty,
+                    attrs: ~[],
                 },
                 span: dummy_sp()
             }
@@ -431,7 +432,6 @@ impl gen_init for protocol {
             dummy_sp(),
             ast::struct_def {
                 fields: fields,
-                dtor: None,
                 ctor_id: None
             },
             cx.strip_bounds(&generics))
diff --git a/src/libsyntax/ext/pipes/proto.rs b/src/libsyntax/ext/pipes/proto.rs
index ffb55ee50d9..647c7741bd8 100644
--- a/src/libsyntax/ext/pipes/proto.rs
+++ b/src/libsyntax/ext/pipes/proto.rs
@@ -217,4 +217,3 @@ pub fn visit<Tproto, Tstate, Tmessage, V: visitor<Tproto, Tstate, Tmessage>>(
     };
     visitor.visit_proto(proto, states)
 }
-
diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs
index f7412a4502c..2bf4b05aa6b 100644
--- a/src/libsyntax/ext/quote.rs
+++ b/src/libsyntax/ext/quote.rs
@@ -760,4 +760,3 @@ fn expand_parse_call(cx: @ext_ctxt,
                           id_ext(cx, parse_method),
                           arg_exprs)
 }
-
diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs
index 70aa9472c85..ab22b3152f4 100644
--- a/src/libsyntax/ext/source_util.rs
+++ b/src/libsyntax/ext/source_util.rs
@@ -150,13 +150,3 @@ fn res_rel_file(cx: @ext_ctxt, sp: codemap::span, arg: &Path) -> Path {
         copy *arg
     }
 }
-
-//
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
-//
diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs
index e4e033e0fff..0c1e619985d 100644
--- a/src/libsyntax/ext/tt/macro_parser.rs
+++ b/src/libsyntax/ext/tt/macro_parser.rs
@@ -438,11 +438,3 @@ pub fn parse_nt(p: &Parser, name: ~str) -> nonterminal {
       _ => p.fatal(~"Unsupported builtin nonterminal parser: " + name)
     }
 }
-
-// Local Variables:
-// mode: rust;
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs
index d82608846ab..229a8664d0c 100644
--- a/src/libsyntax/fold.rs
+++ b/src/libsyntax/fold.rs
@@ -222,9 +222,12 @@ pub fn noop_fold_item(i: @item, fld: @ast_fold) -> Option<@item> {
 
 fn noop_fold_struct_field(sf: @struct_field, fld: @ast_fold)
                        -> @struct_field {
+    let fold_attribute = |x| fold_attribute_(x, fld);
+
     @spanned { node: ast::struct_field_ { kind: copy sf.node.kind,
                                           id: sf.node.id,
-                                          ty: fld.fold_ty(sf.node.ty) },
+                                          ty: fld.fold_ty(sf.node.ty),
+                                          attrs: sf.node.attrs.map(|e| fold_attribute(*e)) },
                span: sf.span }
 }
 
@@ -290,21 +293,8 @@ pub fn noop_fold_item_underscore(i: &item_, fld: @ast_fold) -> item_ {
 
 fn fold_struct_def(struct_def: @ast::struct_def, fld: @ast_fold)
                 -> @ast::struct_def {
-    let dtor = do struct_def.dtor.map |dtor| {
-        let dtor_body = fld.fold_block(&dtor.node.body);
-        let dtor_id   = fld.new_id(dtor.node.id);
-        spanned {
-            node: ast::struct_dtor_ {
-                body: dtor_body,
-                id: dtor_id,
-                .. copy dtor.node
-            },
-            span: copy dtor.span
-        }
-    };
     @ast::struct_def {
         fields: struct_def.fields.map(|f| fold_struct_field(*f, fld)),
-        dtor: dtor,
         ctor_id: struct_def.ctor_id.map(|cid| fld.new_id(*cid)),
     }
 }
@@ -322,6 +312,7 @@ fn fold_struct_field(f: @struct_field, fld: @ast_fold) -> @struct_field {
             kind: copy f.node.kind,
             id: fld.new_id(f.node.id),
             ty: fld.fold_ty(f.node.ty),
+            attrs: /* FIXME (#2543) */ copy f.node.attrs,
         },
         span: fld.new_span(f.span),
     }
@@ -655,22 +646,9 @@ fn noop_fold_variant(v: &variant_, fld: @ast_fold) -> variant_ {
             })
         }
         struct_variant_kind(struct_def) => {
-            let dtor = do struct_def.dtor.map |dtor| {
-                let dtor_body = fld.fold_block(&dtor.node.body);
-                let dtor_id   = fld.new_id(dtor.node.id);
-                spanned {
-                    node: ast::struct_dtor_ {
-                        body: dtor_body,
-                        id: dtor_id,
-                        .. copy dtor.node
-                    },
-                    .. copy *dtor
-                }
-            };
             kind = struct_variant_kind(@ast::struct_def {
                 fields: vec::map(struct_def.fields,
                                  |f| fld.fold_struct_field(*f)),
-                dtor: dtor,
                 ctor_id: struct_def.ctor_id.map(|c| fld.new_id(*c))
             })
         }
@@ -783,6 +761,7 @@ impl ast_fold for AstFoldFns {
                 kind: copy sf.node.kind,
                 id: sf.node.id,
                 ty: (self as @ast_fold).fold_ty(sf.node.ty),
+                attrs: copy sf.node.attrs,
             },
             span: (self.new_span)(sf.span),
         }
@@ -880,13 +859,3 @@ impl AstFoldExtensions for @ast_fold {
 pub fn make_fold(afp: ast_fold_fns) -> @ast_fold {
     afp as @ast_fold
 }
-
-//
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
-//
diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs
index cc580155d70..037b2c089f4 100644
--- a/src/libsyntax/parse/attr.rs
+++ b/src/libsyntax/parse/attr.rs
@@ -179,13 +179,3 @@ impl parser_attr for Parser {
         }
     }
 }
-
-//
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
-//
diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs
index 163c7852132..8956622a06b 100644
--- a/src/libsyntax/parse/lexer.rs
+++ b/src/libsyntax/parse/lexer.rs
@@ -892,13 +892,3 @@ mod test {
         assert_eq!(tok, token::LIFETIME(id));
     }
 }
-
-//
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
-//
diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs
index 5d51a54d770..0c024958a24 100644
--- a/src/libsyntax/parse/mod.rs
+++ b/src/libsyntax/parse/mod.rs
@@ -418,9 +418,10 @@ mod test {
         new_parser_from_source_str(ps,~[],~"bogofile",source_str)
     }
 
-    #[test] fn to_json_str<E : Encodable<std::json::Encoder>>(val: @E) -> ~str {
+    #[cfg(test)] fn to_json_str<E : Encodable<std::json::Encoder>>(val: @E) -> ~str {
         do io::with_str_writer |writer| {
-            val.encode(~std::json::Encoder(writer));
+            let mut encoder = std::json::Encoder(writer);
+            val.encode(&mut encoder);
         }
     }
 
@@ -674,13 +675,3 @@ mod test {
         string_to_expr(@~"a::z.froob(b,@(987+3))");
     }
 }
-
-//
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
-//
diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs
index ce21e0f672d..e486a6254e7 100644
--- a/src/libsyntax/parse/obsolete.rs
+++ b/src/libsyntax/parse/obsolete.rs
@@ -18,7 +18,7 @@ removed.
 */
 
 
-use ast::{expr, expr_lit, lit_nil};
+use ast::{expr, expr_lit, lit_nil, attribute};
 use ast;
 use codemap::{span, respan};
 use parse::parser::Parser;
@@ -282,13 +282,13 @@ pub impl Parser {
         }
     }
 
-    fn try_parse_obsolete_priv_section(&self) -> bool {
+    fn try_parse_obsolete_priv_section(&self, attrs: ~[attribute]) -> bool {
         if self.is_keyword(&~"priv") && self.look_ahead(1) == token::LBRACE {
             self.obsolete(copy *self.span, ObsoletePrivSection);
             self.eat_keyword(&~"priv");
             self.bump();
             while *self.token != token::RBRACE {
-                self.parse_single_struct_field(ast::private);
+                self.parse_single_struct_field(ast::private, attrs);
             }
             self.bump();
             true
@@ -298,4 +298,3 @@ pub impl Parser {
     }
 
 }
-
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 457c6df8db2..4839b179723 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -19,7 +19,7 @@ use ast::{_mod, add, arg, arm, attribute, bind_by_ref, bind_infer};
 use ast::{bind_by_copy, bitand, bitor, bitxor, blk};
 use ast::{blk_check_mode, box};
 use ast::{crate, crate_cfg, decl, decl_item};
-use ast::{decl_local, default_blk, deref, quot, enum_def};
+use ast::{decl_local, default_blk, deref, div, enum_def};
 use ast::{expr, expr_, expr_addr_of, expr_match, expr_again};
 use ast::{expr_assign, expr_assign_op, expr_binary, expr_block};
 use ast::{expr_break, expr_call, expr_cast, expr_copy, expr_do_body};
@@ -102,11 +102,6 @@ enum restriction {
     RESTRICT_NO_BAR_OR_DOUBLEBAR_OP,
 }
 
-//  So that we can distinguish a class dtor from other class members
-
-enum class_contents { dtor_decl(blk, ~[attribute], codemap::span),
-                      members(~[@struct_field]) }
-
 type arg_or_capture_item = Either<arg, ()>;
 type item_info = (ident, item_, Option<~[attribute]>);
 
@@ -313,22 +308,22 @@ pub impl Parser {
         }
         return copy self.buffer[(*self.buffer_start + dist - 1) & 3].tok;
     }
-    fn fatal(&self, m: ~str) -> ! {
+    fn fatal(&self, m: &str) -> ! {
         self.sess.span_diagnostic.span_fatal(*copy self.span, m)
     }
-    fn span_fatal(&self, sp: span, m: ~str) -> ! {
+    fn span_fatal(&self, sp: span, m: &str) -> ! {
         self.sess.span_diagnostic.span_fatal(sp, m)
     }
-    fn span_note(&self, sp: span, m: ~str) {
+    fn span_note(&self, sp: span, m: &str) {
         self.sess.span_diagnostic.span_note(sp, m)
     }
-    fn bug(&self, m: ~str) -> ! {
+    fn bug(&self, m: &str) -> ! {
         self.sess.span_diagnostic.span_bug(*copy self.span, m)
     }
-    fn warn(&self, m: ~str) {
+    fn warn(&self, m: &str) {
         self.sess.span_diagnostic.span_warn(*copy self.span, m)
     }
-    fn span_err(&self, sp: span, m: ~str) {
+    fn span_err(&self, sp: span, m: &str) {
         self.sess.span_diagnostic.span_err(sp, m)
     }
     fn abort_if_errors(&self) {
@@ -937,7 +932,7 @@ pub impl Parser {
         loop {
             match *self.token {
                 token::MOD_SEP => {
-                    match self.look_ahead(1u) {
+                    match self.look_ahead(1) {
                         token::IDENT(*) => {
                             self.bump();
                             ids.push(self.parse_ident());
@@ -1836,7 +1831,7 @@ pub impl Parser {
                   token::PLUS => aop = add,
                   token::MINUS => aop = subtract,
                   token::STAR => aop = mul,
-                  token::SLASH => aop = quot,
+                  token::SLASH => aop = div,
                   token::PERCENT => aop = rem,
                   token::CARET => aop = bitxor,
                   token::AND => aop = bitand,
@@ -2034,8 +2029,7 @@ pub impl Parser {
             // This is a 'continue' expression
             if opt_ident.is_some() {
                 self.span_err(*self.last_span,
-                              ~"a label may not be used with a `loop` \
-                                expression");
+                              "a label may not be used with a `loop` expression");
             }
 
             let lo = self.span.lo;
@@ -2172,7 +2166,7 @@ pub impl Parser {
                     @ast::pat { node: pat_wild, _ } => (),
                     @ast::pat { node: pat_ident(_, _, _), _ } => (),
                     @ast::pat { span, _ } => self.span_fatal(
-                        span, ~"expected an identifier or `_`"
+                        span, "expected an identifier or `_`"
                     )
                 }
                 slice = Some(subpat);
@@ -2464,7 +2458,7 @@ pub impl Parser {
                        -> ast::pat_ {
         if !is_plain_ident(&*self.token) {
             self.span_fatal(*self.last_span,
-                            ~"expected identifier, found path");
+                            "expected identifier, found path");
         }
         // why a path here, and not just an identifier?
         let name = self.parse_path_without_tps();
@@ -2483,7 +2477,7 @@ pub impl Parser {
         if *self.token == token::LPAREN {
             self.span_fatal(
                 *self.last_span,
-                ~"expected identifier, found enum pattern");
+                "expected identifier, found enum pattern");
         }
 
         pat_ident(binding_mode, name, sub)
@@ -2525,7 +2519,9 @@ pub impl Parser {
     }
 
     // parse a structure field
-    fn parse_name_and_ty(&self, pr: visibility) -> @struct_field {
+    fn parse_name_and_ty(&self,
+                         pr: visibility,
+                         attrs: ~[attribute]) -> @struct_field {
         let mut is_mutbl = struct_immutable;
         let lo = self.span.lo;
         if self.eat_keyword(&~"mut") {
@@ -2540,7 +2536,8 @@ pub impl Parser {
         @spanned(lo, self.last_span.hi, ast::struct_field_ {
             kind: named_field(name, is_mutbl, pr),
             id: self.get_id(),
-            ty: ty
+            ty: ty,
+            attrs: attrs,
         })
     }
 
@@ -2611,19 +2608,19 @@ pub impl Parser {
 
             match self.parse_item_or_view_item(/*bad*/ copy item_attrs,
                                                            false) {
-              iovi_item(i) => {
-                let hi = i.span.hi;
-                let decl = @spanned(lo, hi, decl_item(i));
-                return @spanned(lo, hi, stmt_decl(decl, self.get_id()));
-              }
-              iovi_view_item(vi) => {
-                self.span_fatal(vi.span, ~"view items must be declared at \
-                                           the top of the block");
-              }
-              iovi_foreign_item(_) => {
-                  self.fatal(~"foreign items are not allowed here");
-              }
-              iovi_none() => { /* fallthrough */ }
+                iovi_item(i) => {
+                    let hi = i.span.hi;
+                    let decl = @spanned(lo, hi, decl_item(i));
+                    return @spanned(lo, hi, stmt_decl(decl, self.get_id()));
+                }
+                iovi_view_item(vi) => {
+                    self.span_fatal(vi.span,
+                                    "view items must be declared at the top of the block");
+                }
+                iovi_foreign_item(_) => {
+                    self.fatal(~"foreign items are not allowed here");
+                }
+                iovi_none() => { /* fallthrough */ }
             }
 
             check_expected_item(self, item_attrs);
@@ -2824,8 +2821,7 @@ pub impl Parser {
                         result.push(RegionTyParamBound);
                     } else {
                         self.span_err(*self.span,
-                                      ~"`'static` is the only permissible \
-                                        region bound here");
+                                      "`'static` is the only permissible region bound here");
                     }
                     self.bump();
                 }
@@ -3240,7 +3236,7 @@ pub impl Parser {
                     })
                 }
                 _ => {
-                    self.span_err(*self.span, ~"not a trait");
+                    self.span_err(*self.span, "not a trait");
                     None
                 }
             };
@@ -3299,7 +3295,6 @@ pub impl Parser {
         }
 
         let mut fields: ~[@struct_field];
-        let mut the_dtor: Option<(blk, ~[attribute], codemap::span)> = None;
         let is_tuple_like;
 
         if self.eat(&token::LBRACE) {
@@ -3307,26 +3302,8 @@ pub impl Parser {
             is_tuple_like = false;
             fields = ~[];
             while *self.token != token::RBRACE {
-                match self.parse_struct_decl_field() {
-                  dtor_decl(ref blk, ref attrs, s) => {
-                      match the_dtor {
-                        Some((_, _, s_first)) => {
-                          self.span_note(s, fmt!("Duplicate destructor \
-                                     declaration for class %s",
-                                     *self.interner.get(class_name)));
-                          self.span_fatal(copy s_first, ~"First destructor \
-                                                          declared here");
-                        }
-                        None => {
-                          the_dtor = Some((copy *blk, copy *attrs, s));
-                        }
-                      }
-                  }
-                  members(mms) => {
-                    for mms.each |struct_field| {
-                        fields.push(*struct_field)
-                    }
-                  }
+                for self.parse_struct_decl_field().each |struct_field| {
+                    fields.push(*struct_field)
                 }
             }
             if fields.len() == 0 {
@@ -3342,11 +3319,13 @@ pub impl Parser {
                 &token::RPAREN,
                 seq_sep_trailing_allowed(token::COMMA)
             ) |p| {
+                let attrs = self.parse_outer_attributes();
                 let lo = p.span.lo;
                 let struct_field_ = ast::struct_field_ {
                     kind: unnamed_field,
                     id: self.get_id(),
-                    ty: p.parse_ty(false)
+                    ty: p.parse_ty(false),
+                    attrs: attrs,
                 };
                 @spanned(lo, p.span.hi, struct_field_)
             };
@@ -3365,19 +3344,11 @@ pub impl Parser {
             );
         }
 
-        let actual_dtor = do the_dtor.map |dtor| {
-            let (d_body, d_attrs, d_s) = copy *dtor;
-            codemap::spanned { node: ast::struct_dtor_ { id: self.get_id(),
-                                                     attrs: d_attrs,
-                                                     self_id: self.get_id(),
-                                                     body: d_body},
-                       span: d_s}};
         let _ = self.get_id();  // XXX: Workaround for crazy bug.
         let new_id = self.get_id();
         (class_name,
          item_struct(@ast::struct_def {
              fields: fields,
-             dtor: actual_dtor,
              ctor_id: if is_tuple_like { Some(new_id) } else { None }
          }, generics),
          None)
@@ -3391,12 +3362,14 @@ pub impl Parser {
     }
 
     // parse a structure field declaration
-    fn parse_single_struct_field(&self, vis: visibility) -> @struct_field {
+    fn parse_single_struct_field(&self,
+                                 vis: visibility,
+                                 attrs: ~[attribute]) -> @struct_field {
         if self.eat_obsolete_ident("let") {
             self.obsolete(*self.last_span, ObsoleteLet);
         }
 
-        let a_var = self.parse_name_and_ty(vis);
+        let a_var = self.parse_name_and_ty(vis, attrs);
         match *self.token {
             token::SEMI => {
                 self.obsolete(copy *self.span, ObsoleteFieldTerminator);
@@ -3420,34 +3393,27 @@ pub impl Parser {
     }
 
     // parse an element of a struct definition
-    fn parse_struct_decl_field(&self) -> class_contents {
-
-        if self.try_parse_obsolete_priv_section() {
-            return members(~[]);
-        }
+    fn parse_struct_decl_field(&self) -> ~[@struct_field] {
 
         let attrs = self.parse_outer_attributes();
 
+        if self.try_parse_obsolete_priv_section(attrs) {
+            return ~[];
+        }
+
         if self.eat_keyword(&~"priv") {
-            return members(~[self.parse_single_struct_field(private)])
+            return ~[self.parse_single_struct_field(private, attrs)]
         }
 
         if self.eat_keyword(&~"pub") {
-           return members(~[self.parse_single_struct_field(public)]);
+           return ~[self.parse_single_struct_field(public, attrs)];
         }
 
         if self.try_parse_obsolete_struct_ctor() {
-            return members(~[]);
+            return ~[];
         }
 
-        if self.eat_keyword(&~"drop") {
-            let lo = self.last_span.lo;
-            let body = self.parse_block();
-            return dtor_decl(body, attrs, mk_sp(lo, self.last_span.hi))
-        }
-        else {
-           return members(~[self.parse_single_struct_field(inherited)]);
-        }
+        return ~[self.parse_single_struct_field(inherited, attrs)];
     }
 
     // parse visiility: PUB, PRIV, or nothing
@@ -3499,9 +3465,8 @@ pub impl Parser {
             ) {
               iovi_item(item) => items.push(item),
               iovi_view_item(view_item) => {
-                self.span_fatal(view_item.span, ~"view items must be \
-                                                  declared at the top of the \
-                                                  module");
+                self.span_fatal(view_item.span, "view items must be  declared at the top of the \
+                                                 module");
               }
               _ => {
                 self.fatal(
@@ -3793,7 +3758,7 @@ pub impl Parser {
         }
 
         if opt_abis.is_some() {
-            self.span_err(*self.span, ~"an ABI may not be specified here");
+            self.span_err(*self.span, "an ABI may not be specified here");
         }
 
         // extern mod foo;
@@ -3829,44 +3794,16 @@ pub impl Parser {
     // parse a structure-like enum variant definition
     // this should probably be renamed or refactored...
     fn parse_struct_def(&self) -> @struct_def {
-        let mut the_dtor: Option<(blk, ~[attribute], codemap::span)> = None;
         let mut fields: ~[@struct_field] = ~[];
         while *self.token != token::RBRACE {
-            match self.parse_struct_decl_field() {
-                dtor_decl(ref blk, ref attrs, s) => {
-                    match the_dtor {
-                        Some((_, _, s_first)) => {
-                            self.span_note(s, ~"duplicate destructor \
-                                                declaration");
-                            self.span_fatal(copy s_first,
-                                            ~"first destructor \
-                                              declared here");
-                        }
-                        None => {
-                            the_dtor = Some((copy *blk, copy *attrs, s));
-                        }
-                    }
-                }
-                members(mms) => {
-                    for mms.each |struct_field| {
-                        fields.push(*struct_field);
-                    }
-                }
+            for self.parse_struct_decl_field().each |struct_field| {
+                fields.push(*struct_field);
             }
         }
         self.bump();
-        let actual_dtor = do the_dtor.map |dtor| {
-            let (d_body, d_attrs, d_s) = copy *dtor;
-            codemap::spanned { node: ast::struct_dtor_ { id: self.get_id(),
-                                                     attrs: d_attrs,
-                                                     self_id: self.get_id(),
-                                                     body: d_body },
-                      span: d_s }
-        };
 
         return @ast::struct_def {
             fields: fields,
-            dtor: actual_dtor,
             ctor_id: None
         };
     }
@@ -4456,9 +4393,7 @@ pub impl Parser {
                         view_item_extern_mod(*)
                         if !extern_mod_allowed => {
                             self.span_err(view_item.span,
-                                          ~"\"extern mod\" \
-                                            declarations are not \
-                                            allowed here");
+                                          "\"extern mod\" declarations are not allowed here");
                         }
                         view_item_extern_mod(*) => {}
                     }
@@ -4484,8 +4419,7 @@ pub impl Parser {
                     iovi_none => break,
                     iovi_view_item(view_item) => {
                         self.span_err(view_item.span,
-                                      ~"`use` and `extern mod` declarations \
-                                        must precede items");
+                                      "`use` and `extern mod` declarations must precede items");
                     }
                     iovi_item(item) => {
                         items.push(item)
@@ -4520,8 +4454,7 @@ pub impl Parser {
                 iovi_view_item(view_item) => {
                     // I think this can't occur:
                     self.span_err(view_item.span,
-                                  ~"`use` and `extern mod` declarations \
-                                    must precede items");
+                                  "`use` and `extern mod` declarations must precede items");
                 }
                 iovi_item(_) => {
                     // FIXME #5668: this will occur for a macro invocation:
@@ -4568,14 +4501,3 @@ pub impl Parser {
         }
     }
 }
-
-
-//
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
-//
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs
index 0327a3b80da..fe7bd5b3bc1 100644
--- a/src/libsyntax/parse/token.rs
+++ b/src/libsyntax/parse/token.rs
@@ -305,50 +305,47 @@ pub fn is_bar(t: &Token) -> bool {
 pub mod special_idents {
     use ast::ident;
 
-    pub static underscore : ident = ident { repr: 0u, ctxt: 0};
-    pub static anon : ident = ident { repr: 1u, ctxt: 0};
-    pub static dtor : ident = ident { repr: 2u, ctxt: 0}; // 'drop', but that's
-                                                 // reserved
-    pub static invalid : ident = ident { repr: 3u, ctxt: 0}; // ''
-    pub static unary : ident = ident { repr: 4u, ctxt: 0};
-    pub static not_fn : ident = ident { repr: 5u, ctxt: 0};
-    pub static idx_fn : ident = ident { repr: 6u, ctxt: 0};
-    pub static unary_minus_fn : ident = ident { repr: 7u, ctxt: 0};
-    pub static clownshoes_extensions : ident = ident { repr: 8u, ctxt: 0};
-
-    pub static self_ : ident = ident { repr: 9u, ctxt: 0}; // 'self'
+    pub static underscore : ident = ident { repr: 0, ctxt: 0};
+    pub static anon : ident = ident { repr: 1, ctxt: 0};
+    pub static invalid : ident = ident { repr: 2, ctxt: 0}; // ''
+    pub static unary : ident = ident { repr: 3, ctxt: 0};
+    pub static not_fn : ident = ident { repr: 4, ctxt: 0};
+    pub static idx_fn : ident = ident { repr: 5, ctxt: 0};
+    pub static unary_minus_fn : ident = ident { repr: 6, ctxt: 0};
+    pub static clownshoes_extensions : ident = ident { repr: 7, ctxt: 0};
+
+    pub static self_ : ident = ident { repr: 8, ctxt: 0}; // 'self'
 
     /* for matcher NTs */
-    pub static item : ident = ident { repr: 10u, ctxt: 0};
-    pub static block : ident = ident { repr: 11u, ctxt: 0};
-    pub static stmt : ident = ident { repr: 12u, ctxt: 0};
-    pub static pat : ident = ident { repr: 13u, ctxt: 0};
-    pub static expr : ident = ident { repr: 14u, ctxt: 0};
-    pub static ty : ident = ident { repr: 15u, ctxt: 0};
-    pub static ident : ident = ident { repr: 16u, ctxt: 0};
-    pub static path : ident = ident { repr: 17u, ctxt: 0};
-    pub static tt : ident = ident { repr: 18u, ctxt: 0};
-    pub static matchers : ident = ident { repr: 19u, ctxt: 0};
-
-    pub static str : ident = ident { repr: 20u, ctxt: 0}; // for the type
+    pub static item : ident = ident { repr: 9, ctxt: 0};
+    pub static block : ident = ident { repr: 10, ctxt: 0};
+    pub static stmt : ident = ident { repr: 11, ctxt: 0};
+    pub static pat : ident = ident { repr: 12, ctxt: 0};
+    pub static expr : ident = ident { repr: 13, ctxt: 0};
+    pub static ty : ident = ident { repr: 14, ctxt: 0};
+    pub static ident : ident = ident { repr: 15, ctxt: 0};
+    pub static path : ident = ident { repr: 16, ctxt: 0};
+    pub static tt : ident = ident { repr: 17, ctxt: 0};
+    pub static matchers : ident = ident { repr: 18, ctxt: 0};
+
+    pub static str : ident = ident { repr: 19, ctxt: 0}; // for the type
 
     /* outside of libsyntax */
-    pub static ty_visitor : ident = ident { repr: 21u, ctxt: 0};
-    pub static arg : ident = ident { repr: 22u, ctxt: 0};
-    pub static descrim : ident = ident { repr: 23u, ctxt: 0};
-    pub static clownshoe_abi : ident = ident { repr: 24u, ctxt: 0};
-    pub static clownshoe_stack_shim : ident = ident { repr: 25u, ctxt: 0};
-    pub static tydesc : ident = ident { repr: 26u, ctxt: 0};
-    pub static literally_dtor : ident = ident { repr: 27u, ctxt: 0};
-    pub static main : ident = ident { repr: 28u, ctxt: 0};
-    pub static opaque : ident = ident { repr: 29u, ctxt: 0};
-    pub static blk : ident = ident { repr: 30u, ctxt: 0};
-    pub static static : ident = ident { repr: 31u, ctxt: 0};
-    pub static intrinsic : ident = ident { repr: 32u, ctxt: 0};
-    pub static clownshoes_foreign_mod: ident = ident { repr: 33u, ctxt: 0};
-    pub static unnamed_field: ident = ident { repr: 34u, ctxt: 0};
-    pub static c_abi: ident = ident { repr: 35u, ctxt: 0};
-    pub static type_self: ident = ident { repr: 36u, ctxt: 0};    // `Self`
+    pub static ty_visitor : ident = ident { repr: 20, ctxt: 0};
+    pub static arg : ident = ident { repr: 21, ctxt: 0};
+    pub static descrim : ident = ident { repr: 22, ctxt: 0};
+    pub static clownshoe_abi : ident = ident { repr: 23, ctxt: 0};
+    pub static clownshoe_stack_shim : ident = ident { repr: 24, ctxt: 0};
+    pub static tydesc : ident = ident { repr: 25, ctxt: 0};
+    pub static main : ident = ident { repr: 26, ctxt: 0};
+    pub static opaque : ident = ident { repr: 27, ctxt: 0};
+    pub static blk : ident = ident { repr: 28, ctxt: 0};
+    pub static static : ident = ident { repr: 29, ctxt: 0};
+    pub static intrinsic : ident = ident { repr: 30, ctxt: 0};
+    pub static clownshoes_foreign_mod: ident = ident { repr: 31, ctxt: 0};
+    pub static unnamed_field: ident = ident { repr: 32, ctxt: 0};
+    pub static c_abi: ident = ident { repr: 33, ctxt: 0};
+    pub static type_self: ident = ident { repr: 34, ctxt: 0};    // `Self`
 }
 
 pub struct StringRef<'self>(&'self str);
@@ -371,7 +368,7 @@ impl<'self> to_bytes::IterBytes for StringRef<'self> {
 pub fn token_to_binop(tok: Token) -> Option<ast::binop> {
   match tok {
       BINOP(STAR)    => Some(ast::mul),
-      BINOP(SLASH)   => Some(ast::quot),
+      BINOP(SLASH)   => Some(ast::div),
       BINOP(PERCENT) => Some(ast::rem),
       BINOP(PLUS)    => Some(ast::add),
       BINOP(MINUS)   => Some(ast::subtract),
@@ -426,41 +423,39 @@ pub fn mk_fresh_ident_interner() -> @ident_interner {
     let init_vec = ~[
         @~"_",                  // 0
         @~"anon",               // 1
-        @~"drop",               // 2
-        @~"",                   // 3
-        @~"unary",              // 4
-        @~"!",                  // 5
-        @~"[]",                 // 6
-        @~"unary-",             // 7
-        @~"__extensions__",     // 8
-        @~"self",               // 9
-        @~"item",               // 10
-        @~"block",              // 11
-        @~"stmt",               // 12
-        @~"pat",                // 13
-        @~"expr",               // 14
-        @~"ty",                 // 15
-        @~"ident",              // 16
-        @~"path",               // 17
-        @~"tt",                 // 18
-        @~"matchers",           // 19
-        @~"str",                // 20
-        @~"TyVisitor",          // 21
-        @~"arg",                // 22
-        @~"descrim",            // 23
-        @~"__rust_abi",         // 24
-        @~"__rust_stack_shim",  // 25
-        @~"TyDesc",             // 26
-        @~"dtor",               // 27
-        @~"main",               // 28
-        @~"<opaque>",           // 29
-        @~"blk",                // 30
-        @~"static",             // 31
-        @~"intrinsic",          // 32
-        @~"__foreign_mod__",    // 33
-        @~"__field__",          // 34
-        @~"C",                  // 35
-        @~"Self",               // 36
+        @~"",                   // 2
+        @~"unary",              // 3
+        @~"!",                  // 4
+        @~"[]",                 // 5
+        @~"unary-",             // 6
+        @~"__extensions__",     // 7
+        @~"self",               // 8
+        @~"item",               // 9
+        @~"block",              // 10
+        @~"stmt",               // 11
+        @~"pat",                // 12
+        @~"expr",               // 13
+        @~"ty",                 // 14
+        @~"ident",              // 15
+        @~"path",               // 16
+        @~"tt",                 // 17
+        @~"matchers",           // 18
+        @~"str",                // 19
+        @~"TyVisitor",          // 20
+        @~"arg",                // 21
+        @~"descrim",            // 22
+        @~"__rust_abi",         // 23
+        @~"__rust_stack_shim",  // 24
+        @~"TyDesc",             // 25
+        @~"main",               // 26
+        @~"<opaque>",           // 27
+        @~"blk",                // 28
+        @~"static",             // 29
+        @~"intrinsic",          // 30
+        @~"__foreign_mod__",    // 31
+        @~"__field__",          // 32
+        @~"C",                  // 33
+        @~"Self",               // 34
     ];
 
     let rv = @ident_interner {
@@ -561,11 +556,3 @@ pub fn reserved_keyword_table() -> HashSet<~str> {
     }
     return words;
 }
-
-
-// Local Variables:
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs
index c1acee8e2cd..43f62d72a9f 100644
--- a/src/libsyntax/print/pp.rs
+++ b/src/libsyntax/print/pp.rs
@@ -587,14 +587,3 @@ pub fn hardbreak_tok_offset(off: int) -> token {
 }
 
 pub fn hardbreak_tok() -> token { return hardbreak_tok_offset(0); }
-
-
-//
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
-//
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index ff8259e8996..6f3d6604d5b 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -699,13 +699,6 @@ pub fn print_struct(s: @ps,
         nbsp(s);
         bopen(s);
         hardbreak_if_not_bol(s);
-        for struct_def.dtor.each |dtor| {
-          hardbreak_if_not_bol(s);
-          maybe_print_comment(s, dtor.span.lo);
-          print_outer_attributes(s, dtor.node.attrs);
-          head(s, ~"drop");
-          print_block(s, &dtor.node.body);
-        }
 
         for struct_def.fields.each |field| {
             match field.node.kind {
@@ -713,6 +706,7 @@ pub fn print_struct(s: @ps,
                 ast::named_field(ident, mutability, visibility) => {
                     hardbreak_if_not_bol(s);
                     maybe_print_comment(s, field.span.lo);
+                    print_outer_attributes(s, field.node.attrs);
                     print_visibility(s, visibility);
                     if mutability == ast::struct_mutable {
                         word_nbsp(s, ~"mut");
@@ -2292,13 +2286,3 @@ mod test {
         assert_eq!(&varstr,&~"pub principal_skinner");
     }
 }
-
-//
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
-//
diff --git a/src/libsyntax/syntax.rc b/src/libsyntax/syntax.rc
index a401d9eb8ac..b8327de0f13 100644
--- a/src/libsyntax/syntax.rc
+++ b/src/libsyntax/syntax.rc
@@ -22,7 +22,6 @@
 
 #[allow(vecs_implicitly_copyable)];
 #[allow(non_camel_case_types)];
-#[deny(deprecated_mode)];
 #[deny(deprecated_pattern)];
 
 extern mod std(vers = "0.7-pre");
@@ -90,4 +89,3 @@ pub mod ext {
 
     pub mod trace_macros;
 }
-
diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs
index a42f640a175..90dd49d6848 100644
--- a/src/libsyntax/visit.rs
+++ b/src/libsyntax/visit.rs
@@ -11,7 +11,6 @@
 use abi::AbiSet;
 use ast::*;
 use ast;
-use ast_util;
 use codemap::span;
 use parse;
 use opt_vec;
@@ -45,13 +44,6 @@ pub enum fn_kind<'self> {
 
     // |x, y| ...
     fk_fn_block,
-
-    fk_dtor( // class destructor
-        &'self Generics,
-        &'self [attribute],
-        node_id /* self id */,
-        def_id /* parent class id */
-    )
 }
 
 pub fn name_of_fn(fk: &fn_kind) -> ident {
@@ -60,15 +52,13 @@ pub fn name_of_fn(fk: &fn_kind) -> ident {
           name
       }
       fk_anon(*) | fk_fn_block(*) => parse::token::special_idents::anon,
-      fk_dtor(*)                  => parse::token::special_idents::dtor
     }
 }
 
 pub fn generics_of_fn(fk: &fn_kind) -> Generics {
     match *fk {
         fk_item_fn(_, generics, _, _) |
-        fk_method(_, generics, _) |
-        fk_dtor(generics, _, _, _) => {
+        fk_method(_, generics, _) => {
             copy *generics
         }
         fk_anon(*) | fk_fn_block(*) => {
@@ -375,25 +365,6 @@ pub fn visit_method_helper<E: Copy>(m: &method, e: E, v: vt<E>) {
     );
 }
 
-pub fn visit_struct_dtor_helper<E>(dtor: struct_dtor, generics: &Generics,
-                                   parent_id: def_id, e: E, v: vt<E>) {
-    (v.visit_fn)(
-        &fk_dtor(
-            generics,
-            dtor.node.attrs,
-            dtor.node.self_id,
-            parent_id
-        ),
-        &ast_util::dtor_dec(),
-        &dtor.node.body,
-        dtor.span,
-        dtor.node.id,
-        e,
-        v
-    )
-
-}
-
 pub fn visit_fn<E: Copy>(fk: &fn_kind, decl: &fn_decl, body: &blk, _sp: span,
                          _id: node_id, e: E, v: vt<E>) {
     visit_fn_decl(decl, e, v);
@@ -418,23 +389,14 @@ pub fn visit_trait_method<E: Copy>(m: &trait_method, e: E, v: vt<E>) {
 pub fn visit_struct_def<E: Copy>(
     sd: @struct_def,
     _nm: ast::ident,
-    generics: &Generics,
-    id: node_id,
+    _generics: &Generics,
+    _id: node_id,
     e: E,
     v: vt<E>
 ) {
     for sd.fields.each |f| {
         (v.visit_struct_field)(*f, e, v);
     }
-    for sd.dtor.each |dtor| {
-        visit_struct_dtor_helper(
-            *dtor,
-            generics,
-            ast_util::local_def(id),
-            e,
-            v
-        )
-    }
 }
 
 pub fn visit_struct_field<E: Copy>(sf: @struct_field, e: E, v: vt<E>) {
@@ -801,11 +763,3 @@ pub fn mk_simple_visitor(v: simple_visitor) -> vt<()> {
             v_struct_method(v.visit_struct_method, a, b, c)
     });
 }
-
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
diff --git a/src/llvm b/src/llvm
-Subproject 56dd407f4f97a01b8df6554c569170d2fc276fc
+Subproject 2e9f0d21fe321849a4759a01fc28eae82ef196d
diff --git a/src/rt/arch/arm/_context.S b/src/rt/arch/arm/_context.S
index 9097ebfc070..6441f59a4d3 100644
--- a/src/rt/arch/arm/_context.S
+++ b/src/rt/arch/arm/_context.S
@@ -48,5 +48,3 @@ swap_registers:
 	msr cpsr_cxsf, r2
 
 	mov pc, lr
-
-
diff --git a/src/rt/arch/arm/gpr.cpp b/src/rt/arch/arm/gpr.cpp
index 6dd385fb330..77ec9d5182a 100644
--- a/src/rt/arch/arm/gpr.cpp
+++ b/src/rt/arch/arm/gpr.cpp
@@ -14,4 +14,3 @@ void rust_gpr::load() {
     LOAD(r8);  LOAD(r9);  LOAD(r10); LOAD(r11);
     LOAD(r12); LOAD(r13); LOAD(r14); LOAD(r15);
 }
-
diff --git a/src/rt/arch/arm/gpr.h b/src/rt/arch/arm/gpr.h
index 49db1429903..c8a3e916a37 100644
--- a/src/rt/arch/arm/gpr.h
+++ b/src/rt/arch/arm/gpr.h
@@ -21,4 +21,3 @@ public:
 };
 
 #endif
-
diff --git a/src/rt/arch/arm/morestack.S b/src/rt/arch/arm/morestack.S
index 4f1431a3392..f0ec3f4b7a5 100644
--- a/src/rt/arch/arm/morestack.S
+++ b/src/rt/arch/arm/morestack.S
@@ -35,7 +35,7 @@ __morestack:
     mov r0, r4         // The amount of stack needed
     add r1, fp, #20    // Address of stack arguments
     mov r2, r5         // Size of stack arguments
-    
+
     // Create new stack
     bl upcall_new_stack@plt
 
@@ -64,7 +64,7 @@ __morestack:
     // Restore return value
 	mov r0, r4
 	mov r1, r5
-	
+
     // Return
     pop {r6, fp, lr}
     mov pc, lr
diff --git a/src/rt/arch/arm/record_sp.S b/src/rt/arch/arm/record_sp.S
index fe680004a89..95fce8746a1 100644
--- a/src/rt/arch/arm/record_sp.S
+++ b/src/rt/arch/arm/record_sp.S
@@ -28,4 +28,3 @@ get_sp_limit:
 get_sp:
 	mov r0, sp
 	mov pc, lr
-
diff --git a/src/rt/arch/arm/regs.h b/src/rt/arch/arm/regs.h
index 2b44bd3af35..0d1c24e0fb7 100644
--- a/src/rt/arch/arm/regs.h
+++ b/src/rt/arch/arm/regs.h
@@ -19,5 +19,3 @@
 #   define RUSTRT_ARG1_S r1
 #   define RUSTRT_ARG2_S r2
 #   define RUSTRT_ARG3_S r3
-
-
diff --git a/src/rt/arch/i386/_context.S b/src/rt/arch/i386/_context.S
index d2643d07c3d..e2e4ffe35b4 100644
--- a/src/rt/arch/i386/_context.S
+++ b/src/rt/arch/i386/_context.S
@@ -63,5 +63,3 @@ SWAP_REGISTERS:
 
     // Return!
     jmp *48(%eax)
-
-
diff --git a/src/rt/arch/i386/gpr.cpp b/src/rt/arch/i386/gpr.cpp
index bebf8019427..e5a59d664b0 100644
--- a/src/rt/arch/i386/gpr.cpp
+++ b/src/rt/arch/i386/gpr.cpp
@@ -20,4 +20,3 @@ void rust_gpr::load() {
     LOAD(eax); LOAD(ebx); LOAD(ecx); LOAD(edx);
     LOAD(esi); LOAD(edi); LOAD(ebp); LOAD(esi);
 }
-
diff --git a/src/rt/arch/i386/gpr.h b/src/rt/arch/i386/gpr.h
index 6ae53e113f4..1953170301c 100644
--- a/src/rt/arch/i386/gpr.h
+++ b/src/rt/arch/i386/gpr.h
@@ -29,4 +29,3 @@ public:
 };
 
 #endif
-
diff --git a/src/rt/arch/i386/morestack.S b/src/rt/arch/i386/morestack.S
index e8a9c1312ed..c1cd11fa432 100644
--- a/src/rt/arch/i386/morestack.S
+++ b/src/rt/arch/i386/morestack.S
@@ -97,7 +97,7 @@
 #endif
 .globl MORESTACK
 
-// FIXME: What about _WIN32?	
+// FIXME: What about _WIN32?
 #if defined(__linux__) || defined(__FreeBSD__)
 	.hidden MORESTACK
 #else
@@ -253,4 +253,3 @@ L_upcall_del_stack$stub:
 
 	.subsections_via_symbols
 #endif
-
diff --git a/src/rt/arch/mips/gpr.h b/src/rt/arch/mips/gpr.h
index 4ff0729633a..b48c1d4e732 100644
--- a/src/rt/arch/mips/gpr.h
+++ b/src/rt/arch/mips/gpr.h
@@ -30,4 +30,3 @@ public:
 };
 
 #endif
-
diff --git a/src/rt/arch/x86_64/_context.S b/src/rt/arch/x86_64/_context.S
index bedd6855467..f718cac9634 100644
--- a/src/rt/arch/x86_64/_context.S
+++ b/src/rt/arch/x86_64/_context.S
@@ -121,4 +121,3 @@ SWAP_REGISTERS:
         // Jump to the instruction pointer
         // found in regs:
         jmp *(RUSTRT_IP*8)(ARG1)
-
diff --git a/src/rt/arch/x86_64/gpr.cpp b/src/rt/arch/x86_64/gpr.cpp
index cf43125923a..37247d1dfdc 100644
--- a/src/rt/arch/x86_64/gpr.cpp
+++ b/src/rt/arch/x86_64/gpr.cpp
@@ -22,4 +22,3 @@ void rust_gpr::load() {
     LOAD(r8);  LOAD(r9);  LOAD(r10); LOAD(r11);
     LOAD(r12); LOAD(r13); LOAD(r14); LOAD(r15);
 }
-
diff --git a/src/rt/arch/x86_64/gpr.h b/src/rt/arch/x86_64/gpr.h
index 75c3b081e77..18ef77dbba6 100644
--- a/src/rt/arch/x86_64/gpr.h
+++ b/src/rt/arch/x86_64/gpr.h
@@ -30,4 +30,3 @@ public:
 };
 
 #endif
-
diff --git a/src/rt/arch/x86_64/regs.h b/src/rt/arch/x86_64/regs.h
index 7d0efd1eec8..1aca452df10 100644
--- a/src/rt/arch/x86_64/regs.h
+++ b/src/rt/arch/x86_64/regs.h
@@ -43,5 +43,3 @@
 #   define RUSTRT_ARG4_S %r8
 #   define RUSTRT_ARG5_S %r9
 #endif
-
-
diff --git a/src/rt/boxed_region.cpp b/src/rt/boxed_region.cpp
index d159df03dc3..a49b52bffe1 100644
--- a/src/rt/boxed_region.cpp
+++ b/src/rt/boxed_region.cpp
@@ -27,11 +27,11 @@ rust_opaque_box *boxed_region::malloc(type_desc *td, size_t body_size) {
     if (live_allocs) live_allocs->prev = box;
     live_allocs = box;
 
-    LOG(rust_get_current_task(), box,
+    /*LOG(rust_get_current_task(), box,
         "@malloc()=%p with td %p, size %lu==%lu+%lu, "
         "align %lu, prev %p, next %p\n",
         box, td, total_size, sizeof(rust_opaque_box), body_size,
-        td->align, box->prev, box->next);
+        td->align, box->prev, box->next);*/
 
     return box;
 }
@@ -50,9 +50,9 @@ rust_opaque_box *boxed_region::realloc(rust_opaque_box *box,
     if (new_box->next) new_box->next->prev = new_box;
     if (live_allocs == box) live_allocs = new_box;
 
-    LOG(rust_get_current_task(), box,
+    /*LOG(rust_get_current_task(), box,
         "@realloc()=%p with orig=%p, size %lu==%lu+%lu",
-        new_box, box, total_size, sizeof(rust_opaque_box), new_size);
+        new_box, box, total_size, sizeof(rust_opaque_box), new_size);*/
 
     return new_box;
 }
@@ -74,15 +74,15 @@ void boxed_region::free(rust_opaque_box *box) {
     // double frees (kind of).
     assert(box->td != NULL);
 
-    LOG(rust_get_current_task(), box,
+    /*LOG(rust_get_current_task(), box,
         "@free(%p) with td %p, prev %p, next %p\n",
-        box, box->td, box->prev, box->next);
+        box, box->td, box->prev, box->next);*/
 
     if (box->prev) box->prev->next = box->next;
     if (box->next) box->next->prev = box->prev;
     if (live_allocs == box) live_allocs = box->next;
 
-    if (env->poison_on_free) {
+    if (poison_on_free) {
         memset(box_body(box), 0xab, box->td->size);
     }
 
diff --git a/src/rt/boxed_region.h b/src/rt/boxed_region.h
index 4097b6d41b7..178772007e5 100644
--- a/src/rt/boxed_region.h
+++ b/src/rt/boxed_region.h
@@ -24,7 +24,7 @@ struct rust_env;
  * a type descr which describes the payload (what follows the header). */
 class boxed_region {
 private:
-    rust_env *env;
+    bool poison_on_free;
     memory_region *backing_region;
     rust_opaque_box *live_allocs;
 
@@ -41,8 +41,8 @@ private:
     boxed_region& operator=(const boxed_region& rhs);
 
 public:
-    boxed_region(rust_env *e, memory_region *br)
-        : env(e)
+    boxed_region(memory_region *br, bool poison_on_free)
+        : poison_on_free(poison_on_free)
         , backing_region(br)
         , live_allocs(NULL)
     {}
diff --git a/src/rt/isaac/rand.h b/src/rt/isaac/rand.h
index 3da2d71b20b..c28b35e688d 100644
--- a/src/rt/isaac/rand.h
+++ b/src/rt/isaac/rand.h
@@ -52,5 +52,3 @@ void isaac(randctx *r);
      (r)->randrsl[(r)->randcnt])
 
 #endif  /* RAND */
-
-
diff --git a/src/rt/memory_region.cpp b/src/rt/memory_region.cpp
index 6de9d5a1df4..f3406712cb0 100644
--- a/src/rt/memory_region.cpp
+++ b/src/rt/memory_region.cpp
@@ -11,7 +11,6 @@
 
 #include "sync/sync.h"
 #include "memory_region.h"
-#include "rust_env.h"
 
 #if RUSTRT_TRACK_ALLOCATIONS >= 3
 #include <execinfo.h>
@@ -35,15 +34,19 @@ void *memory_region::get_data(alloc_header *ptr) {
     return (void*)((char *)ptr + HEADER_SIZE);
 }
 
-memory_region::memory_region(rust_env *env, bool synchronized) :
-    _env(env), _parent(NULL), _live_allocations(0),
-    _detailed_leaks(env->detailed_leaks),
+memory_region::memory_region(bool synchronized,
+                             bool detailed_leaks,
+                             bool poison_on_free) :
+    _parent(NULL), _live_allocations(0),
+    _detailed_leaks(detailed_leaks),
+    _poison_on_free(poison_on_free),
     _synchronized(synchronized) {
 }
 
 memory_region::memory_region(memory_region *parent) :
-    _env(parent->_env), _parent(parent), _live_allocations(0),
+    _parent(parent), _live_allocations(0),
     _detailed_leaks(parent->_detailed_leaks),
+    _poison_on_free(parent->_poison_on_free),
     _synchronized(parent->_synchronized) {
 }
 
@@ -241,7 +244,7 @@ memory_region::claim_alloc(void *mem) {
 void
 memory_region::maybe_poison(void *mem) {
 
-    if (!_env->poison_on_free)
+    if (!_poison_on_free)
         return;
 
 #   if RUSTRT_TRACK_ALLOCATIONS >= 1
diff --git a/src/rt/memory_region.h b/src/rt/memory_region.h
index 999a992eefa..4ad57c11809 100644
--- a/src/rt/memory_region.h
+++ b/src/rt/memory_region.h
@@ -54,11 +54,11 @@ private:
     inline alloc_header *get_header(void *mem);
     inline void *get_data(alloc_header *);
 
-    rust_env *_env;
     memory_region *_parent;
     int _live_allocations;
     array_list<alloc_header *> _allocation_list;
     const bool _detailed_leaks;
+    const bool _poison_on_free;
     const bool _synchronized;
     lock_and_signal _lock;
 
@@ -75,7 +75,8 @@ private:
     memory_region& operator=(const memory_region& rhs);
 
 public:
-    memory_region(rust_env *env, bool synchronized);
+    memory_region(bool synchronized,
+                  bool detailed_leaks, bool poison_on_free);
     memory_region(memory_region *parent);
     void *malloc(size_t size, const char *tag);
     void *realloc(void *mem, size_t size);
diff --git a/src/rt/rust_abi.cpp b/src/rt/rust_abi.cpp
index ca8448b39a1..fd1b7860b29 100644
--- a/src/rt/rust_abi.cpp
+++ b/src/rt/rust_abi.cpp
@@ -86,4 +86,3 @@ symbolicate(const std::vector<frame> &frames) {
 }
 
 }   // end namespace stack_walk
-
diff --git a/src/rt/rust_abi.h b/src/rt/rust_abi.h
index c56bf96291f..4179bf75157 100644
--- a/src/rt/rust_abi.h
+++ b/src/rt/rust_abi.h
@@ -76,4 +76,3 @@ std::string symbolicate(const std::vector<frame> &frames);
 uint32_t get_abi_version();
 
 #endif
-
diff --git a/src/rt/rust_android_dummy.cpp b/src/rt/rust_android_dummy.cpp
index 3c7034a2f95..b6fe78288e9 100644
--- a/src/rt/rust_android_dummy.cpp
+++ b/src/rt/rust_android_dummy.cpp
@@ -2,12 +2,12 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#ifdef __ANDROID__
+
 #include "rust_android_dummy.h"
 #include <math.h>
 #include <errno.h>
 
-#ifdef __ANDROID__
-
 int backtrace(void **array, int size) { return 0; }
 
 char **backtrace_symbols(void *const *array, int size) { return 0; }
@@ -59,7 +59,21 @@ extern "C" void srand()
 extern "C" void atof()
 {
 }
+
 extern "C" void tgammaf()
 {
 }
+
+extern "C" int glob(const char *pattern,
+                    int flags,
+                    int (*errfunc) (const char *epath, int eerrno),
+                    glob_t *pglob)
+{
+    return 0;
+}
+
+extern "C" void globfree(glob_t *pglob)
+{
+}
+
 #endif
diff --git a/src/rt/rust_android_dummy.h b/src/rt/rust_android_dummy.h
index 95a1774894b..d2329a46c83 100644
--- a/src/rt/rust_android_dummy.h
+++ b/src/rt/rust_android_dummy.h
@@ -11,5 +11,27 @@ char **backtrace_symbols (void *__const *__array, int __size);
 
 void backtrace_symbols_fd (void *__const *__array, int __size, int __fd);
 
-#endif
+#include <sys/types.h>
+
+struct stat;
+typedef struct {
+    size_t gl_pathc;    /* Count of total paths so far. */
+    size_t gl_matchc;   /* Count of paths matching pattern. */
+    size_t gl_offs;     /* Reserved at beginning of gl_pathv. */
+    int gl_flags;       /* Copy of flags parameter to glob. */
+    char **gl_pathv;    /* List of paths matching pattern. */
+                /* Copy of errfunc parameter to glob. */
+    int (*gl_errfunc)(const char *, int);
 
+    /*
+     * Alternate filesystem access methods for glob; replacement
+     * versions of closedir(3), readdir(3), opendir(3), stat(2)
+     * and lstat(2).
+     */
+    void (*gl_closedir)(void *);
+    struct dirent *(*gl_readdir)(void *);
+    void *(*gl_opendir)(const char *);
+    int (*gl_lstat)(const char *, struct stat *);
+} glob_t;
+
+#endif
diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp
index 197b8b36d2d..a491379153e 100644
--- a/src/rt/rust_builtin.cpp
+++ b/src/rt/rust_builtin.cpp
@@ -870,6 +870,63 @@ rust_initialize_global_state() {
     }
 }
 
+extern "C" CDECL memory_region*
+rust_new_memory_region(uintptr_t synchronized,
+                       uintptr_t detailed_leaks,
+                       uintptr_t poison_on_free) {
+    return new memory_region((bool)synchronized,
+                             (bool)detailed_leaks,
+                             (bool)poison_on_free);
+}
+
+extern "C" CDECL void
+rust_delete_memory_region(memory_region *region) {
+    delete region;
+}
+
+extern "C" CDECL boxed_region*
+rust_new_boxed_region(memory_region *region,
+                      uintptr_t poison_on_free) {
+    return new boxed_region(region, poison_on_free);
+}
+
+extern "C" CDECL void
+rust_delete_boxed_region(boxed_region *region) {
+    delete region;
+}
+
+extern "C" CDECL rust_opaque_box*
+rust_boxed_region_malloc(boxed_region *region, type_desc *td, size_t size) {
+    return region->malloc(td, size);
+}
+
+extern "C" CDECL void
+rust_boxed_region_free(boxed_region *region, rust_opaque_box *box) {
+    region->free(box);
+}
+
+typedef void *(rust_try_fn)(void*, void*);
+
+extern "C" CDECL uintptr_t
+rust_try(rust_try_fn f, void *fptr, void *env) {
+    try {
+        f(fptr, env);
+    } catch (uintptr_t token) {
+        assert(token != 0);
+        return token;
+    }
+    return 0;
+}
+
+extern "C" CDECL void
+rust_begin_unwind(uintptr_t token) {
+#ifndef __WIN32__
+    throw token;
+#else
+    abort();
+#endif
+}
+
 //
 // Local Variables:
 // mode: C++
diff --git a/src/rt/rust_debug.cpp b/src/rt/rust_debug.cpp
index 5c5be45bef8..f403b0434b6 100644
--- a/src/rt/rust_debug.cpp
+++ b/src/rt/rust_debug.cpp
@@ -58,4 +58,3 @@ dump_origin(rust_task *task, void *ptr) {
 }
 
 }   // end namespace debug
-
diff --git a/src/rt/rust_debug.h b/src/rt/rust_debug.h
index c9aad098d38..7f025bb908e 100644
--- a/src/rt/rust_debug.h
+++ b/src/rt/rust_debug.h
@@ -70,4 +70,3 @@ void dump_origin(rust_task *task, void *ptr);
 }   // end namespace debug
 
 #endif
-
diff --git a/src/rt/rust_gpr_base.h b/src/rt/rust_gpr_base.h
index 4df6ea3e9ad..7ec2dda9cd4 100644
--- a/src/rt/rust_gpr_base.h
+++ b/src/rt/rust_gpr_base.h
@@ -31,4 +31,3 @@ public:
 
 
 #endif
-
diff --git a/src/rt/rust_run_program.cpp b/src/rt/rust_run_program.cpp
index cf4beed1a00..0ba76078691 100644
--- a/src/rt/rust_run_program.cpp
+++ b/src/rt/rust_run_program.cpp
@@ -15,212 +15,44 @@
 #include <crt_externs.h>
 #endif
 
-struct RunProgramResult {
-    pid_t pid;
-    void* handle;
-};
-
 #if defined(__WIN32__)
 
-#include <process.h>
-#include <io.h>
-
-bool backslash_run_ends_in_quote(char const *c) {
-    while (*c == '\\') ++c;
-    return *c == '"';
-}
-
-void append_first_char(char *&buf, char const *c) {
-    switch (*c) {
-
-    case '"':
-        // Escape quotes.
-        *buf++ = '\\';
-        *buf++ = '"';
-        break;
-
-
-    case '\\':
-        if (backslash_run_ends_in_quote(c)) {
-            // Double all backslashes that are in runs before quotes.
-            *buf++ = '\\';
-            *buf++ = '\\';
-        } else {
-            // Pass other backslashes through unescaped.
-            *buf++ = '\\';
-        }
-        break;
-
-    default:
-        *buf++ = *c;
-    }
+extern "C" CDECL void
+rust_unset_sigprocmask() {
+    // empty stub for windows to keep linker happy
 }
 
-bool contains_whitespace(char const *arg) {
-    while (*arg) {
-        switch (*arg++) {
-        case ' ':
-        case '\t':
-            return true;
-        }
-    }
-    return false;
-}
-
-void append_arg(char *& buf, char const *arg, bool last) {
-    bool quote = contains_whitespace(arg);
-    if (quote)
-        *buf++ = '"';
-    while (*arg)
-        append_first_char(buf, arg++);
-    if (quote)
-        *buf++ = '"';
-
-    if (! last) {
-        *buf++ = ' ';
-    } else {
-        *buf++ = '\0';
-    }
-}
-
-extern "C" CDECL RunProgramResult
-rust_run_program(const char* argv[],
-                 void* envp,
-                 const char* dir,
-                 int in_fd, int out_fd, int err_fd) {
-    STARTUPINFO si;
-    ZeroMemory(&si, sizeof(STARTUPINFO));
-    si.cb = sizeof(STARTUPINFO);
-    si.dwFlags = STARTF_USESTDHANDLES;
-
-    RunProgramResult result = {-1, NULL};
-
-    HANDLE curproc = GetCurrentProcess();
-    HANDLE origStdin = (HANDLE)_get_osfhandle(in_fd ? in_fd : 0);
-    if (!DuplicateHandle(curproc, origStdin,
-        curproc, &si.hStdInput, 0, 1, DUPLICATE_SAME_ACCESS))
-        return result;
-    HANDLE origStdout = (HANDLE)_get_osfhandle(out_fd ? out_fd : 1);
-    if (!DuplicateHandle(curproc, origStdout,
-        curproc, &si.hStdOutput, 0, 1, DUPLICATE_SAME_ACCESS))
-        return result;
-    HANDLE origStderr = (HANDLE)_get_osfhandle(err_fd ? err_fd : 2);
-    if (!DuplicateHandle(curproc, origStderr,
-        curproc, &si.hStdError, 0, 1, DUPLICATE_SAME_ACCESS))
-        return result;
-
-    size_t cmd_len = 0;
-    for (const char** arg = argv; *arg; arg++) {
-        cmd_len += strlen(*arg);
-        cmd_len += 3; // Two quotes plus trailing space or \0
-    }
-    cmd_len *= 2; // Potentially backslash-escape everything.
-
-    char* cmd = (char*)malloc(cmd_len);
-    char* pos = cmd;
-    for (const char** arg = argv; *arg; arg++) {
-        append_arg(pos, *arg, *(arg+1) == NULL);
-    }
-
-    PROCESS_INFORMATION pi;
-    BOOL created = CreateProcess(NULL, cmd, NULL, NULL, TRUE,
-                                 0, envp, dir, &si, &pi);
-
-    CloseHandle(si.hStdInput);
-    CloseHandle(si.hStdOutput);
-    CloseHandle(si.hStdError);
-    free(cmd);
-
-    if (!created) {
-        return result;
-    }
-
-    // We close the thread handle because we don't care about keeping the thread id valid,
-    // and we aren't keeping the thread handle around to be able to close it later. We don't
-    // close the process handle however because we want the process id to stay valid at least
-    // until the calling rust code closes the process handle.
-    CloseHandle(pi.hThread);
-    result.pid = pi.dwProcessId;
-    result.handle = pi.hProcess;
-    return result;
-}
-
-extern "C" CDECL int
-rust_process_wait(int pid) {
-
-    HANDLE proc = OpenProcess(SYNCHRONIZE | PROCESS_QUERY_INFORMATION, FALSE, pid);
-    if (proc == NULL) {
-        return -1;
-    }
-
-    DWORD status;
-    while (true) {
-        if (!GetExitCodeProcess(proc, &status)) {
-            CloseHandle(proc);
-            return -1;
-        }
-        if (status != STILL_ACTIVE) {
-            CloseHandle(proc);
-            return (int) status;
-        }
-        WaitForSingleObject(proc, INFINITE);
-    }
+extern "C" CDECL void
+rust_set_environ(void* envp) {
+    // empty stub for windows to keep linker happy
 }
 
 #elif defined(__GNUC__)
 
-#include <sys/file.h>
 #include <signal.h>
-#include <sys/ioctl.h>
 #include <unistd.h>
-#include <termios.h>
 
 #ifdef __FreeBSD__
 extern char **environ;
 #endif
 
-extern "C" CDECL RunProgramResult
-rust_run_program(const char* argv[],
-                 void* envp,
-                 const char* dir,
-                 int in_fd, int out_fd, int err_fd) {
-    int pid = fork();
-    if (pid != 0) {
-        RunProgramResult result = {pid, NULL};
-        return result;
-    }
-
+extern "C" CDECL void
+rust_unset_sigprocmask() {
+    // this can't be safely converted to rust code because the
+    // representation of sigset_t is platform-dependent
     sigset_t sset;
     sigemptyset(&sset);
     sigprocmask(SIG_SETMASK, &sset, NULL);
+}
 
-    if (in_fd) dup2(in_fd, 0);
-    if (out_fd) dup2(out_fd, 1);
-    if (err_fd) dup2(err_fd, 2);
-    /* Close all other fds. */
-    for (int fd = getdtablesize() - 1; fd >= 3; fd--) close(fd);
-    if (dir) {
-        int result = chdir(dir);
-        // FIXME (#2674): need error handling
-        assert(!result && "chdir failed");
-    }
-
-    if (envp) {
+extern "C" CDECL void
+rust_set_environ(void* envp) {
+    // FIXME: this could actually be converted to rust (see issue #2674)
 #ifdef __APPLE__
-        *_NSGetEnviron() = (char **)envp;
+    *_NSGetEnviron() = (char **) envp;
 #else
-        environ = (char **)envp;
+    environ = (char **) envp;
 #endif
-    }
-
-    execvp(argv[0], (char * const *)argv);
-    exit(1);
-}
-
-extern "C" CDECL int
-rust_process_wait(int pid) {
-    // FIXME: stub; exists to placate linker. (#2692)
-    return 0;
 }
 
 #else
diff --git a/src/rt/rust_sched_loop.cpp b/src/rt/rust_sched_loop.cpp
index dbcbd7b83cf..2911b970b13 100644
--- a/src/rt/rust_sched_loop.cpp
+++ b/src/rt/rust_sched_loop.cpp
@@ -38,7 +38,7 @@ rust_sched_loop::rust_sched_loop(rust_scheduler *sched, int id, bool killed) :
     sched(sched),
     log_lvl(log_debug),
     min_stack_size(kernel->env->min_stack_size),
-    local_region(kernel->env, false),
+    local_region(false, kernel->env->detailed_leaks, kernel->env->poison_on_free),
     // FIXME #2891: calculate a per-scheduler name.
     name("main")
 {
diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp
index ea42936f2e5..23e70535768 100644
--- a/src/rt/rust_task.cpp
+++ b/src/rt/rust_task.cpp
@@ -36,7 +36,7 @@ rust_task::rust_task(rust_sched_loop *sched_loop, rust_task_state state,
     kernel(sched_loop->kernel),
     name(name),
     list_index(-1),
-    boxed(sched_loop->kernel->env, &local_region),
+    boxed(&local_region, sched_loop->kernel->env->poison_on_free),
     local_region(&sched_loop->local_region),
     unwinding(false),
     total_stack_sz(0),
diff --git a/src/rt/rust_task.h b/src/rt/rust_task.h
index dc45c0439ea..b76a177e1c8 100644
--- a/src/rt/rust_task.h
+++ b/src/rt/rust_task.h
@@ -175,6 +175,10 @@
 #define RED_ZONE_SIZE RZ_MAC_32
 #endif
 
+#ifndef RED_ZONE_SIZE
+# error "Red zone not defined for this platform"
+#endif
+
 struct frame_glue_fns {
     uintptr_t mark_glue_off;
     uintptr_t drop_glue_off;
diff --git a/src/rt/rust_test_helpers.cpp b/src/rt/rust_test_helpers.cpp
index 64966bd3454..d82c39d6838 100644
--- a/src/rt/rust_test_helpers.cpp
+++ b/src/rt/rust_test_helpers.cpp
@@ -165,3 +165,14 @@ extern "C" CDECL TwoDoubles
 rust_dbg_extern_identity_TwoDoubles(TwoDoubles u) {
     return u;
 }
+
+// Generates increasing port numbers for network testing
+extern "C" CDECL uintptr_t
+rust_dbg_next_port() {
+  static lock_and_signal dbg_port_lock;
+  static uintptr_t next_port = 9600;
+  scoped_lock with(dbg_port_lock);
+  uintptr_t this_port = next_port;
+  next_port += 1;
+  return this_port;
+}
diff --git a/src/rt/rust_upcall.cpp b/src/rt/rust_upcall.cpp
index 59f06feee4b..658fdec6df2 100644
--- a/src/rt/rust_upcall.cpp
+++ b/src/rt/rust_upcall.cpp
@@ -293,7 +293,13 @@ upcall_rust_personality(int version,
     s_rust_personality_args args = {(_Unwind_Reason_Code)0,
                                     version, actions, exception_class,
                                     ue_header, context};
-    rust_task *task = rust_get_current_task();
+    rust_task *task = rust_try_get_current_task();
+
+    if (task == NULL) {
+        // Assuming we're running with the new scheduler
+        upcall_s_rust_personality(&args);
+        return args.retval;
+    }
 
     // The personality function is run on the stack of the
     // last function that threw or landed, which is going
@@ -330,8 +336,12 @@ upcall_del_stack() {
 // needs to acquire the value of the stack pointer
 extern "C" CDECL void
 upcall_reset_stack_limit() {
-    rust_task *task = rust_get_current_task();
-    task->reset_stack_limit();
+    rust_task *task = rust_try_get_current_task();
+    if (task != NULL) {
+        task->reset_stack_limit();
+    } else {
+        // We must be in a newsched task
+    }
 }
 
 //
diff --git a/src/rt/rustrt.def.in b/src/rt/rustrt.def.in
index 977e0248ca2..3ca05b94711 100644
--- a/src/rt/rustrt.def.in
+++ b/src/rt/rustrt.def.in
@@ -37,8 +37,8 @@ rust_list_dir_wfd_size
 rust_list_dir_wfd_fp_buf
 rust_log_console_on
 rust_log_console_off
-rust_process_wait
-rust_run_program
+rust_set_environ
+rust_unset_sigprocmask
 rust_sched_current_nonlazy_threads
 rust_sched_threads
 rust_set_exit_status
@@ -224,4 +224,12 @@ rust_uv_free_ip4_addr
 rust_uv_free_ip6_addr
 rust_call_nullary_fn
 rust_initialize_global_state
-
+rust_dbg_next_port
+rust_new_memory_region
+rust_delete_memory_region
+rust_new_boxed_region
+rust_delete_boxed_region
+rust_boxed_region_malloc
+rust_boxed_region_free
+rust_try
+rust_begin_unwind
diff --git a/src/rustllvm/README b/src/rustllvm/README
index 31495f22c0a..c0db3f68a76 100644
--- a/src/rustllvm/README
+++ b/src/rustllvm/README
@@ -1,3 +1,2 @@
 This directory currently contains some LLVM support code. This will generally
 be sent upstream to LLVM in time; for now it lives here.
-
diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp
index 451a390876c..04e616de223 100644
--- a/src/rustllvm/RustWrapper.cpp
+++ b/src/rustllvm/RustWrapper.cpp
@@ -120,18 +120,18 @@ void LLVMRustInitializeTargets() {
   LLVMInitializeX86TargetMC();
   LLVMInitializeX86AsmPrinter();
   LLVMInitializeX86AsmParser();
-	
+
   LLVMInitializeARMTargetInfo();
   LLVMInitializeARMTarget();
   LLVMInitializeARMTargetMC();
   LLVMInitializeARMAsmPrinter();
-  LLVMInitializeARMAsmParser();	
+  LLVMInitializeARMAsmParser();
 
   LLVMInitializeMipsTargetInfo();
   LLVMInitializeMipsTarget();
   LLVMInitializeMipsTargetMC();
   LLVMInitializeMipsAsmPrinter();
-  LLVMInitializeMipsAsmParser();	
+  LLVMInitializeMipsAsmParser();
 }
 
 // Custom memory manager for MCJITting. It needs special features
@@ -438,7 +438,7 @@ LLVMRustWriteOutputFile(LLVMPassManagerRef PMR,
                         const char *path,
                         TargetMachine::CodeGenFileType FileType,
                         CodeGenOpt::Level OptLevel,
-			bool EnableSegmentedStacks) {
+      bool EnableSegmentedStacks) {
 
   LLVMRustInitializeTargets();
 
@@ -449,7 +449,7 @@ LLVMRustWriteOutputFile(LLVMPassManagerRef PMR,
   if (!EnableARMEHABI) {
     int argc = 3;
     const char* argv[] = {"rustc", "-arm-enable-ehabi",
-			  "-arm-enable-ehabi-descriptors"};
+        "-arm-enable-ehabi-descriptors"};
     cl::ParseCommandLineOptions(argc, argv);
   }
 
@@ -467,8 +467,8 @@ LLVMRustWriteOutputFile(LLVMPassManagerRef PMR,
   const Target *TheTarget = TargetRegistry::lookupTarget(Trip, Err);
   TargetMachine *Target =
     TheTarget->createTargetMachine(Trip, CPUStr, FeaturesStr,
-				   Options, Reloc::PIC_,
-				   CodeModel::Default, OptLevel);
+           Options, Reloc::PIC_,
+           CodeModel::Default, OptLevel);
   Target->addAnalysisPasses(*PM);
 
   bool NoVerify = false;
@@ -511,10 +511,10 @@ extern "C" LLVMValueRef LLVMRustConstSmallInt(LLVMTypeRef IntTy, unsigned N,
   return LLVMConstInt(IntTy, (unsigned long long)N, SignExtend);
 }
 
-extern "C" LLVMValueRef LLVMRustConstInt(LLVMTypeRef IntTy, 
-					 unsigned N_hi,
-					 unsigned N_lo,
-					 LLVMBool SignExtend) {
+extern "C" LLVMValueRef LLVMRustConstInt(LLVMTypeRef IntTy,
+           unsigned N_hi,
+           unsigned N_lo,
+           LLVMBool SignExtend) {
   unsigned long long N = N_hi;
   N <<= 32;
   N |= N_lo;
diff --git a/src/snapshots.txt b/src/snapshots.txt
index fafd5467655..c643b4dd25d 100644
--- a/src/snapshots.txt
+++ b/src/snapshots.txt
@@ -1,3 +1,11 @@
+S 2013-05-03 213f7b2
+  macos-i386 0bf8b88ea01cc4cdd81ac4db1d301ea9b3371f13
+  macos-x86_64 2da3990639ab5a9c9d51b3478c437cb459de84e3
+  linux-i386 094500e587bfac27d7be752b635c242e07774c0d
+  linux-x86_64 75733a5a58f53aa783253c8cfd56923b78676705
+  winnt-i386 bd07c935a917c0796d4dc803d973b864d4794ade
+  freebsd-x86_64 b95d648d9bfeacdd04cc5213bdc803b0fd94add7
+
 S 2013-03-28 f7a2371
   macos-i386 2e05a33716fc4982db53946c3b0dccf0194826fe
   macos-x86_64 fbd3feec8dd17a6b6c8df114e6e9b4cd17cc6172
@@ -151,7 +159,7 @@ S 2012-10-03 5585514
   winnt-i386 25680d15a358cf4163e08f4e56e54fb497de5eb4
 
 S 2012-10-02 4d30b34
-  macos-i386 2bcce3cde8a7e53df202972cda85b0b59ce4e50d 
+  macos-i386 2bcce3cde8a7e53df202972cda85b0b59ce4e50d
   macos-x86_64 fc5592828392f9eabe8b51cc59639be6d709cc26
   freebsd-x86_64 5e09dad0800f16f5d79286330bcb82b6d2b8782e
   linux-i386 92fc541d4dde19fe2af5930d72a5a50ca67bad60
diff --git a/src/test/auxiliary/anon_trait_static_method_lib.rs b/src/test/auxiliary/anon_trait_static_method_lib.rs
index 9a778b18874..6e111381cba 100644
--- a/src/test/auxiliary/anon_trait_static_method_lib.rs
+++ b/src/test/auxiliary/anon_trait_static_method_lib.rs
@@ -17,4 +17,3 @@ pub impl Foo {
         Foo { x: 3 }
     }
 }
-
diff --git a/src/test/auxiliary/cci_class_2.rs b/src/test/auxiliary/cci_class_2.rs
index 9dc27054ef7..b120a4d759f 100644
--- a/src/test/auxiliary/cci_class_2.rs
+++ b/src/test/auxiliary/cci_class_2.rs
@@ -27,4 +27,3 @@ pub mod kitties {
         }
     }
 }
-
diff --git a/src/test/auxiliary/cci_class_6.rs b/src/test/auxiliary/cci_class_6.rs
index 80990099cda..b09606ea1e2 100644
--- a/src/test/auxiliary/cci_class_6.rs
+++ b/src/test/auxiliary/cci_class_6.rs
@@ -31,4 +31,3 @@ pub mod kitties {
         }
     }
 }
-
diff --git a/src/test/auxiliary/cci_class_cast.rs b/src/test/auxiliary/cci_class_cast.rs
index edda0644b16..ae0407a5bed 100644
--- a/src/test/auxiliary/cci_class_cast.rs
+++ b/src/test/auxiliary/cci_class_cast.rs
@@ -56,5 +56,3 @@ pub mod kitty {
         }
     }
 }
-
-
diff --git a/src/test/auxiliary/cci_no_inline_lib.rs b/src/test/auxiliary/cci_no_inline_lib.rs
index 407f62adb02..f79227d87cd 100644
--- a/src/test/auxiliary/cci_no_inline_lib.rs
+++ b/src/test/auxiliary/cci_no_inline_lib.rs
@@ -19,4 +19,3 @@ pub fn iter(v: ~[uint], f: &fn(uint)) {
         i += 1u;
     }
 }
-
diff --git a/src/test/auxiliary/explicit_self_xcrate.rs b/src/test/auxiliary/explicit_self_xcrate.rs
index c790252244f..058cb53f918 100644
--- a/src/test/auxiliary/explicit_self_xcrate.rs
+++ b/src/test/auxiliary/explicit_self_xcrate.rs
@@ -23,5 +23,3 @@ impl Foo for Bar {
         io::println((*self).x);
     }
 }
-
-
diff --git a/src/test/auxiliary/extern_mod_ordering_lib.rs b/src/test/auxiliary/extern_mod_ordering_lib.rs
index 8276cea465f..d04351203da 100644
--- a/src/test/auxiliary/extern_mod_ordering_lib.rs
+++ b/src/test/auxiliary/extern_mod_ordering_lib.rs
@@ -3,4 +3,3 @@
 pub mod extern_mod_ordering_lib {
     pub fn f() {}
 }
-
diff --git a/src/test/auxiliary/foreign_lib.rs b/src/test/auxiliary/foreign_lib.rs
index 1561ec51ede..fe5b9e45593 100644
--- a/src/test/auxiliary/foreign_lib.rs
+++ b/src/test/auxiliary/foreign_lib.rs
@@ -15,4 +15,3 @@ pub mod rustrt {
         pub fn rust_get_argc() -> libc::c_int;
     }
 }
-
diff --git a/src/test/auxiliary/impl_privacy_xc_1.rs b/src/test/auxiliary/impl_privacy_xc_1.rs
index 92452cbe8fd..4d98c4d9d2b 100644
--- a/src/test/auxiliary/impl_privacy_xc_1.rs
+++ b/src/test/auxiliary/impl_privacy_xc_1.rs
@@ -7,4 +7,3 @@ pub struct Fish {
 pub impl Fish {
     fn swim(&self) {}
 }
-
diff --git a/src/test/auxiliary/impl_privacy_xc_2.rs b/src/test/auxiliary/impl_privacy_xc_2.rs
index 0fa15fa14f6..7ef36b1fb66 100644
--- a/src/test/auxiliary/impl_privacy_xc_2.rs
+++ b/src/test/auxiliary/impl_privacy_xc_2.rs
@@ -11,5 +11,3 @@ mod unexported {
         fn ne(&self, _: &Fish) -> bool { false }
     }
 }
-
-
diff --git a/src/test/auxiliary/issue-2196-c.rc b/src/test/auxiliary/issue-2196-c.rc
deleted file mode 100644
index 59c1e8108c0..00000000000
--- a/src/test/auxiliary/issue-2196-c.rc
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#[link(name = "issue2196c", vers = "0.1")];
-#[crate_type = "lib"];
-
-use b(name = "issue2196b");
-#[path = "issue-2196-d.rs"]
-mod d;
diff --git a/src/test/auxiliary/issue-2196-d.rs b/src/test/auxiliary/issue-2196-d.rs
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/src/test/auxiliary/issue-2196-d.rs
+++ /dev/null
diff --git a/src/test/auxiliary/issue-2414-a.rs b/src/test/auxiliary/issue-2414-a.rs
index 9f4f369b70d..54bb39fd2df 100644
--- a/src/test/auxiliary/issue-2414-a.rs
+++ b/src/test/auxiliary/issue-2414-a.rs
@@ -20,4 +20,3 @@ trait foo {
 impl foo for ~str {
     fn foo(&self) {}
 }
-
diff --git a/src/test/auxiliary/issue-2414-b.rs b/src/test/auxiliary/issue-2414-b.rs
index 4bebe4e1420..f4ef02a2b7f 100644
--- a/src/test/auxiliary/issue-2414-b.rs
+++ b/src/test/auxiliary/issue-2414-b.rs
@@ -14,4 +14,3 @@
 #[crate_type = "lib"];
 
 extern mod a;
-
diff --git a/src/test/auxiliary/issue-2526.rs b/src/test/auxiliary/issue-2526.rs
index fa32b9603a5..0e9cf39929f 100644
--- a/src/test/auxiliary/issue-2526.rs
+++ b/src/test/auxiliary/issue-2526.rs
@@ -55,4 +55,3 @@ fn context_res() -> context_res {
 }
 
 pub type context = arc_destruct<context_res>;
-
diff --git a/src/test/auxiliary/issue2378a.rs b/src/test/auxiliary/issue2378a.rs
index ead338c4bc8..1873aca5909 100644
--- a/src/test/auxiliary/issue2378a.rs
+++ b/src/test/auxiliary/issue2378a.rs
@@ -8,13 +8,16 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+#[link (name = "issue2378a")];
+#[crate_type = "lib"];
+
 enum maybe<T> { just(T), nothing }
 
-impl copy> for maybe<T> for methods<T {
-    fn ~[](idx: uint) -> T {
+impl <T:Copy> Index<uint,T> for maybe<T> {
+    fn index(&self, idx: &uint) -> T {
         match self {
-          just(t) { t }
-          nothing { fail!(); }
+            &just(ref t) => copy *t,
+            &nothing => { fail!(); }
         }
     }
 }
diff --git a/src/test/auxiliary/issue2378b.rs b/src/test/auxiliary/issue2378b.rs
index 9037417ef62..20f07a5cb54 100644
--- a/src/test/auxiliary/issue2378b.rs
+++ b/src/test/auxiliary/issue2378b.rs
@@ -8,15 +8,17 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use issue2378a;
+#[link (name = "issue2378b")];
+#[crate_type = "lib"];
+
+extern mod issue2378a;
 
 use issue2378a::maybe;
-use issue2378a::methods;
 
-type two_maybes<T> = {a: maybe<T>, b: maybe<T>};
+struct two_maybes<T> {a: maybe<T>, b: maybe<T>}
 
-impl copy> for two_maybes<T> for methods<T {
-    fn ~[](idx: uint) -> (T, T) {
-        (self.a[idx], self.b[idx])
+impl <T:Copy> Index<uint,(T,T)> for two_maybes<T> {
+    fn index(&self, idx: &uint) -> (T, T) {
+        (self.a[*idx], self.b[*idx])
     }
 }
diff --git a/src/test/auxiliary/issue_2316_b.rs b/src/test/auxiliary/issue_2316_b.rs
index ed8e69cb4da..32283e5373c 100644
--- a/src/test/auxiliary/issue_2316_b.rs
+++ b/src/test/auxiliary/issue_2316_b.rs
@@ -17,5 +17,3 @@ pub mod cloth {
         gingham, flannel, calico
     }
 }
-
-
diff --git a/src/test/auxiliary/issue_3136_a.rs b/src/test/auxiliary/issue_3136_a.rs
index f7c866da9ae..55de208cc90 100644
--- a/src/test/auxiliary/issue_3136_a.rs
+++ b/src/test/auxiliary/issue_3136_a.rs
@@ -12,7 +12,7 @@ trait x {
     fn use_x<T>(&self);
 }
 struct y(());
-impl x for y { 
+impl x for y {
     fn use_x<T>(&self) {
         struct foo { //~ ERROR quux
             i: ()
@@ -20,6 +20,5 @@ impl x for y {
         fn new_foo<T>(i: ()) -> foo {
             foo { i: i }
         }
-    }   
+    }
 }
-
diff --git a/src/test/auxiliary/issue_3882.rs b/src/test/auxiliary/issue_3882.rs
index 63275a05598..bb75758c741 100644
--- a/src/test/auxiliary/issue_3882.rs
+++ b/src/test/auxiliary/issue_3882.rs
@@ -12,7 +12,7 @@ mod issue_3882 {
     struct Completions {
         len: libc::size_t,
     }
-    
+
     mod c {
         extern {
             fn linenoiseAddCompletion(lc: *mut Completions);
diff --git a/src/test/auxiliary/moves_based_on_type_lib.rs b/src/test/auxiliary/moves_based_on_type_lib.rs
index 826bd0db129..857593a84d2 100644
--- a/src/test/auxiliary/moves_based_on_type_lib.rs
+++ b/src/test/auxiliary/moves_based_on_type_lib.rs
@@ -25,4 +25,3 @@ pub fn f() {
     let y = x;
     let z = y;
 }
-
diff --git a/src/test/auxiliary/newtype_struct_xc.rs b/src/test/auxiliary/newtype_struct_xc.rs
index 90036e0f96c..e0d2541dbe3 100644
--- a/src/test/auxiliary/newtype_struct_xc.rs
+++ b/src/test/auxiliary/newtype_struct_xc.rs
@@ -1,4 +1,3 @@
 #[crate_type="lib"];
 
 pub struct Au(int);
-
diff --git a/src/test/auxiliary/pub_use_mods_xcrate.rs b/src/test/auxiliary/pub_use_mods_xcrate.rs
index e085f2312dc..e4890f4fe2d 100644
--- a/src/test/auxiliary/pub_use_mods_xcrate.rs
+++ b/src/test/auxiliary/pub_use_mods_xcrate.rs
@@ -18,4 +18,3 @@ pub mod a {
         }
     }
 }
-
diff --git a/src/test/auxiliary/static_fn_inline_xc_aux.rs b/src/test/auxiliary/static_fn_inline_xc_aux.rs
index 5fc6621f186..a17a78bcea7 100644
--- a/src/test/auxiliary/static_fn_inline_xc_aux.rs
+++ b/src/test/auxiliary/static_fn_inline_xc_aux.rs
@@ -21,4 +21,3 @@ pub mod float {
         fn from_int2(n: int) -> float { return n as float;  }
     }
 }
-
diff --git a/src/test/auxiliary/struct_destructuring_cross_crate.rs b/src/test/auxiliary/struct_destructuring_cross_crate.rs
index ab7b1a636d3..8887cbee3fe 100644
--- a/src/test/auxiliary/struct_destructuring_cross_crate.rs
+++ b/src/test/auxiliary/struct_destructuring_cross_crate.rs
@@ -14,4 +14,3 @@ pub struct S {
     x: int,
     y: int
 }
-
diff --git a/src/test/auxiliary/trait_inheritance_auto_xc_2_aux.rs b/src/test/auxiliary/trait_inheritance_auto_xc_2_aux.rs
index 1c7ebd941c3..7d6178db485 100644
--- a/src/test/auxiliary/trait_inheritance_auto_xc_2_aux.rs
+++ b/src/test/auxiliary/trait_inheritance_auto_xc_2_aux.rs
@@ -17,5 +17,3 @@ pub struct A { x: int }
 impl Foo for A { fn f(&self) -> int { 10 } }
 impl Bar for A { fn g(&self) -> int { 20 } }
 impl Baz for A { fn h(&self) -> int { 30 } }
-
-
diff --git a/src/test/auxiliary/trait_inheritance_overloading_xc.rs b/src/test/auxiliary/trait_inheritance_overloading_xc.rs
index 1b480ff17b3..1fb0db25b31 100644
--- a/src/test/auxiliary/trait_inheritance_overloading_xc.rs
+++ b/src/test/auxiliary/trait_inheritance_overloading_xc.rs
@@ -38,4 +38,3 @@ impl Eq for MyInt {
 impl MyNum for MyInt;
 
 fn mi(v: int) -> MyInt { MyInt { val: v } }
-
diff --git a/src/test/auxiliary/xc_private_method_lib.rs b/src/test/auxiliary/xc_private_method_lib.rs
index f9fda2b0810..05325c3b935 100644
--- a/src/test/auxiliary/xc_private_method_lib.rs
+++ b/src/test/auxiliary/xc_private_method_lib.rs
@@ -7,4 +7,3 @@ pub struct Foo {
 impl Foo {
     fn new() -> Foo { Foo { x: 1 } }
 }
-
diff --git a/src/test/bench/msgsend-pipes-shared.rs b/src/test/bench/msgsend-pipes-shared.rs
index 3833c884652..6cda0a1945a 100644
--- a/src/test/bench/msgsend-pipes-shared.rs
+++ b/src/test/bench/msgsend-pipes-shared.rs
@@ -104,7 +104,7 @@ fn main() {
         ~[~"", ~"10000", ~"4"]
     } else {
         copy args
-    };        
+    };
 
     debug!("%?", args);
     run(args);
diff --git a/src/test/bench/msgsend-pipes.rs b/src/test/bench/msgsend-pipes.rs
index c4044d45f36..a8fb29a47e2 100644
--- a/src/test/bench/msgsend-pipes.rs
+++ b/src/test/bench/msgsend-pipes.rs
@@ -101,7 +101,7 @@ fn main() {
         ~[~"", ~"10000", ~"4"]
     } else {
         copy args
-    };        
+    };
 
     debug!("%?", args);
     run(args);
diff --git a/src/test/bench/msgsend-ring-mutex-arcs.rs b/src/test/bench/msgsend-ring-mutex-arcs.rs
index a1ab7384d62..853b057277d 100644
--- a/src/test/bench/msgsend-ring-mutex-arcs.rs
+++ b/src/test/bench/msgsend-ring-mutex-arcs.rs
@@ -72,7 +72,7 @@ fn main() {
         ~[~"", ~"10", ~"100"]
     } else {
         copy args
-    }; 
+    };
 
     let num_tasks = uint::from_str(args[1]).get();
     let msg_per_task = uint::from_str(args[2]).get();
diff --git a/src/test/bench/msgsend-ring-pipes.rs b/src/test/bench/msgsend-ring-pipes.rs
index 14e955dd7bd..1288ac29078 100644
--- a/src/test/bench/msgsend-ring-pipes.rs
+++ b/src/test/bench/msgsend-ring-pipes.rs
@@ -65,7 +65,7 @@ fn main() {
         ~[~"", ~"100", ~"1000"]
     } else {
         copy args
-    }; 
+    };
 
     let num_tasks = uint::from_str(args[1]).get();
     let msg_per_task = uint::from_str(args[2]).get();
diff --git a/src/test/bench/msgsend-ring-rw-arcs.rs b/src/test/bench/msgsend-ring-rw-arcs.rs
index 8e819cc4aba..2cf0fbfc397 100644
--- a/src/test/bench/msgsend-ring-rw-arcs.rs
+++ b/src/test/bench/msgsend-ring-rw-arcs.rs
@@ -73,7 +73,7 @@ fn main() {
         ~[~"", ~"10", ~"100"]
     } else {
         copy args
-    }; 
+    };
 
     let num_tasks = uint::from_str(args[1]).get();
     let msg_per_task = uint::from_str(args[2]).get();
diff --git a/src/test/bench/pingpong.rs b/src/test/bench/pingpong.rs
index 4a6e90f4116..09e663325ed 100644
--- a/src/test/bench/pingpong.rs
+++ b/src/test/bench/pingpong.rs
@@ -11,7 +11,7 @@
 // Compare bounded and unbounded protocol performance.
 
 // xfail-pretty
- 
+
 extern mod std;
 
 use core::cell::Cell;
diff --git a/src/test/bench/shootout-binarytrees.rs b/src/test/bench/shootout-binarytrees.rs
index 8d0675d0884..c420e0cbb2f 100644
--- a/src/test/bench/shootout-binarytrees.rs
+++ b/src/test/bench/shootout-binarytrees.rs
@@ -1,3 +1,7 @@
+// xfail-test
+
+// Broken due to arena API problems.
+
 // 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.
@@ -10,7 +14,6 @@
 
 extern mod std;
 use std::arena;
-use methods = std::arena::Arena;
 
 enum tree<'self> {
     nil,
@@ -26,9 +29,7 @@ fn item_check(t: &tree) -> int {
     }
 }
 
-fn bottom_up_tree<'r>(arena: &'r arena::Arena,
-                      item: int,
-                      depth: int)
+fn bottom_up_tree<'r>(arena: &'r mut arena::Arena, item: int, depth: int)
                    -> &'r tree<'r> {
     if depth > 0 {
         return arena.alloc(
@@ -58,25 +59,25 @@ fn main() {
         max_depth = n;
     }
 
-    let stretch_arena = arena::Arena();
+    let mut stretch_arena = arena::Arena();
     let stretch_depth = max_depth + 1;
-    let stretch_tree = bottom_up_tree(&stretch_arena, 0, stretch_depth);
+    let stretch_tree = bottom_up_tree(&mut stretch_arena, 0, stretch_depth);
 
     io::println(fmt!("stretch tree of depth %d\t check: %d",
                           stretch_depth,
                           item_check(stretch_tree)));
 
-    let long_lived_arena = arena::Arena();
-    let long_lived_tree = bottom_up_tree(&long_lived_arena, 0, max_depth);
+    let mut long_lived_arena = arena::Arena();
+    let long_lived_tree = bottom_up_tree(&mut long_lived_arena, 0, max_depth);
     let mut depth = min_depth;
     while depth <= max_depth {
         let iterations = int::pow(2, (max_depth - depth + min_depth) as uint);
         let mut chk = 0;
         let mut i = 1;
         while i <= iterations {
-            let mut temp_tree = bottom_up_tree(&long_lived_arena, i, depth);
+            let mut temp_tree = bottom_up_tree(&mut long_lived_arena, i, depth);
             chk += item_check(temp_tree);
-            temp_tree = bottom_up_tree(&long_lived_arena, -i, depth);
+            temp_tree = bottom_up_tree(&mut long_lived_arena, -i, depth);
             chk += item_check(temp_tree);
             i += 1;
         }
@@ -87,5 +88,5 @@ fn main() {
     }
     io::println(fmt!("long lived trees of depth %d\t check: %d",
                      max_depth,
-                          item_check(long_lived_tree)));
+                     item_check(long_lived_tree)));
 }
diff --git a/src/test/bench/shootout-chameneos-redux.rs b/src/test/bench/shootout-chameneos-redux.rs
index 9dad24646de..5d893d4ec07 100644
--- a/src/test/bench/shootout-chameneos-redux.rs
+++ b/src/test/bench/shootout-chameneos-redux.rs
@@ -218,4 +218,3 @@ fn main() {
     rendezvous(nn,
         ~[Blue, Red, Yellow, Red, Yellow, Blue, Red, Yellow, Red, Blue]);
 }
-
diff --git a/src/test/bench/shootout-fannkuch-redux.rs b/src/test/bench/shootout-fannkuch-redux.rs
index 21f38245ca3..cb32e0e496e 100644
--- a/src/test/bench/shootout-fannkuch-redux.rs
+++ b/src/test/bench/shootout-fannkuch-redux.rs
@@ -92,4 +92,3 @@ fn main() {
     let n: i32 = FromStr::from_str(os::args()[1]).get();
     println(fmt!("Pfannkuchen(%d) = %d", n as int, fannkuch_redux(n) as int));
 }
-
diff --git a/src/test/bench/shootout-fasta-redux.rs b/src/test/bench/shootout-fasta-redux.rs
index 5ece9810206..d6a0f4b8b25 100644
--- a/src/test/bench/shootout-fasta-redux.rs
+++ b/src/test/bench/shootout-fasta-redux.rs
@@ -201,4 +201,3 @@ fn main() {
         fputc('\n' as c_int, stdout);
     }
 }
-
diff --git a/src/test/bench/shootout-k-nucleotide-pipes.rs b/src/test/bench/shootout-k-nucleotide-pipes.rs
index 4cd7b58ce12..d1f3dbf22ce 100644
--- a/src/test/bench/shootout-k-nucleotide-pipes.rs
+++ b/src/test/bench/shootout-k-nucleotide-pipes.rs
@@ -222,4 +222,3 @@ fn main() {
       io::println(from_child[ii].recv());
    }
 }
-
diff --git a/src/test/bench/shootout-k-nucleotide.rs b/src/test/bench/shootout-k-nucleotide.rs
index 224885a3f79..1791af67ed0 100644
--- a/src/test/bench/shootout-k-nucleotide.rs
+++ b/src/test/bench/shootout-k-nucleotide.rs
@@ -252,7 +252,7 @@ fn generate_frequencies(frequencies: &mut Table,
                         mut input: &[u8],
                         frame: i32) {
     let mut code = Code(0);
-    
+
     // Pull first frame.
     for (frame as uint).times {
         code = code.push_char(input[0]);
@@ -313,4 +313,3 @@ fn main() {
         print_occurrences(frequencies, occurrence);
     }
 }
-
diff --git a/src/test/bench/shootout-mandelbrot.rs b/src/test/bench/shootout-mandelbrot.rs
index e62cb8ea849..7d2b25792ec 100644
--- a/src/test/bench/shootout-mandelbrot.rs
+++ b/src/test/bench/shootout-mandelbrot.rs
@@ -57,4 +57,3 @@ fn main() {
         }
     }
 }
-
diff --git a/src/test/bench/shootout-pidigits.rs b/src/test/bench/shootout-pidigits.rs
index 38e87358ee2..cb7fa969be7 100644
--- a/src/test/bench/shootout-pidigits.rs
+++ b/src/test/bench/shootout-pidigits.rs
@@ -175,4 +175,3 @@ fn main() {
     let n: u32 = FromStr::from_str(os::args()[1]).get();
     pidigits(n);
 }
-
diff --git a/src/test/bench/shootout-reverse-complement.rs b/src/test/bench/shootout-reverse-complement.rs
index 72c01c8d55c..a9cb3c7636a 100644
--- a/src/test/bench/shootout-reverse-complement.rs
+++ b/src/test/bench/shootout-reverse-complement.rs
@@ -152,4 +152,3 @@ fn main() {
         fwrite(transmute(out.unsafe_ref(0)), 1, pos as size_t, stdout);
     }
 }
-
diff --git a/src/test/bench/sudoku.rs b/src/test/bench/sudoku.rs
index 9221da8b557..8afddd3a31e 100644
--- a/src/test/bench/sudoku.rs
+++ b/src/test/bench/sudoku.rs
@@ -274,4 +274,3 @@ fn main() {
     sudoku.solve();
     sudoku.write(io::stdout());
 }
-
diff --git a/src/test/compile-fail/alt-tag-nullary.rs b/src/test/compile-fail/alt-tag-nullary.rs
index c74ee3d852a..2b0c3dbf8e8 100644
--- a/src/test/compile-fail/alt-tag-nullary.rs
+++ b/src/test/compile-fail/alt-tag-nullary.rs
@@ -14,4 +14,3 @@ enum a { A, }
 enum b { B, }
 
 fn main() { let x: a = A; match x { B => { } } }
-
diff --git a/src/test/compile-fail/alt-tag-unary.rs b/src/test/compile-fail/alt-tag-unary.rs
index e01b9a045e5..a129ff19ac6 100644
--- a/src/test/compile-fail/alt-tag-unary.rs
+++ b/src/test/compile-fail/alt-tag-unary.rs
@@ -14,4 +14,3 @@ enum a { A(int), }
 enum b { B(int), }
 
 fn main() { let x: a = A(0); match x { B(y) => { } } }
-
diff --git a/src/test/compile-fail/alt-vec-mismatch-2.rs b/src/test/compile-fail/alt-vec-mismatch-2.rs
index 9e8fb84951d..6ea0300cf1e 100644
--- a/src/test/compile-fail/alt-vec-mismatch-2.rs
+++ b/src/test/compile-fail/alt-vec-mismatch-2.rs
@@ -1,5 +1,5 @@
 fn main() {
     match () {
-        [()] => { } //~ ERROR mismatched type: expected `()` but found vector
+        [()] => { } //~ ERROR mismatched types: expected `()` but found a vector pattern
     }
 }
diff --git a/src/test/compile-fail/alt-vec-mismatch.rs b/src/test/compile-fail/alt-vec-mismatch.rs
index ef4d92ea491..85ed8761ee9 100644
--- a/src/test/compile-fail/alt-vec-mismatch.rs
+++ b/src/test/compile-fail/alt-vec-mismatch.rs
@@ -1,6 +1,6 @@
 fn main() {
     match ~"foo" {
-        ['f', 'o', .._] => { } //~ ERROR mismatched type: expected `~str` but found vector
+        ['f', 'o', .._] => { } //~ ERROR mismatched types: expected `~str` but found a vector pattern
         _ => { }
     }
 }
diff --git a/src/test/compile-fail/bogus-tag.rs b/src/test/compile-fail/bogus-tag.rs
index 12e8ba56532..89ad7b4245a 100644
--- a/src/test/compile-fail/bogus-tag.rs
+++ b/src/test/compile-fail/bogus-tag.rs
@@ -21,4 +21,3 @@ fn main() {
       hsl(h, s, l) => { debug!("hsl"); }
     }
 }
-
diff --git a/src/test/compile-fail/borrowck-assign-comp-idx.rs b/src/test/compile-fail/borrowck-assign-comp-idx.rs
index d447d9e4a22..9b21cbf9768 100644
--- a/src/test/compile-fail/borrowck-assign-comp-idx.rs
+++ b/src/test/compile-fail/borrowck-assign-comp-idx.rs
@@ -47,4 +47,3 @@ fn c() {
 
 fn main() {
 }
-
diff --git a/src/test/compile-fail/borrowck-assign-comp.rs b/src/test/compile-fail/borrowck-assign-comp.rs
index b8c0cbe9743..ccd0542ca7f 100644
--- a/src/test/compile-fail/borrowck-assign-comp.rs
+++ b/src/test/compile-fail/borrowck-assign-comp.rs
@@ -44,4 +44,3 @@ fn d() {
 
 fn main() {
 }
-
diff --git a/src/test/compile-fail/borrowck-auto-mut-ref-to-immut-var.rs b/src/test/compile-fail/borrowck-auto-mut-ref-to-immut-var.rs
index ce95ee94f42..2ba5d0473cc 100644
--- a/src/test/compile-fail/borrowck-auto-mut-ref-to-immut-var.rs
+++ b/src/test/compile-fail/borrowck-auto-mut-ref-to-immut-var.rs
@@ -24,4 +24,3 @@ fn main() {
     let x = Foo { x: 3 };
     x.printme();    //~ ERROR cannot borrow
 }
-
diff --git a/src/test/compile-fail/borrowck-call-method-from-mut-aliasable.rs b/src/test/compile-fail/borrowck-call-method-from-mut-aliasable.rs
index be51091c1fd..3abd19e5a11 100644
--- a/src/test/compile-fail/borrowck-call-method-from-mut-aliasable.rs
+++ b/src/test/compile-fail/borrowck-call-method-from-mut-aliasable.rs
@@ -40,4 +40,3 @@ fn c(x: &const Foo) {
 
 fn main() {
 }
-
diff --git a/src/test/compile-fail/borrowck-loan-local-as-both-mut-and-imm.rs b/src/test/compile-fail/borrowck-loan-local-as-both-mut-and-imm.rs
index f369bf208c2..6e8e3da143e 100644
--- a/src/test/compile-fail/borrowck-loan-local-as-both-mut-and-imm.rs
+++ b/src/test/compile-fail/borrowck-loan-local-as-both-mut-and-imm.rs
@@ -30,6 +30,6 @@ use core::either::{Either, Left, Right};
         let y: &Either<int, float> = &x;
         let z: &mut Either<int, float> = &mut x; //~ ERROR cannot borrow
         *z = *y;
-    } 
+    }
 
     fn main() {}
diff --git a/src/test/compile-fail/borrowck-loan-rcvr-overloaded-op.rs b/src/test/compile-fail/borrowck-loan-rcvr-overloaded-op.rs
index 2c4ae242fb4..061a6c553e4 100644
--- a/src/test/compile-fail/borrowck-loan-rcvr-overloaded-op.rs
+++ b/src/test/compile-fail/borrowck-loan-rcvr-overloaded-op.rs
@@ -57,4 +57,3 @@ fn c() {
 
 fn main() {
 }
-
diff --git a/src/test/compile-fail/borrowck-loan-rcvr.rs b/src/test/compile-fail/borrowck-loan-rcvr.rs
index decf6228fc6..27a66557434 100644
--- a/src/test/compile-fail/borrowck-loan-rcvr.rs
+++ b/src/test/compile-fail/borrowck-loan-rcvr.rs
@@ -59,4 +59,3 @@ fn c() {
 
 fn main() {
 }
-
diff --git a/src/test/compile-fail/borrowck-mut-boxed-vec.rs b/src/test/compile-fail/borrowck-mut-boxed-vec.rs
index a69edebce51..716f70b2913 100644
--- a/src/test/compile-fail/borrowck-mut-boxed-vec.rs
+++ b/src/test/compile-fail/borrowck-mut-boxed-vec.rs
@@ -14,4 +14,3 @@ fn main() {
         v[1] = 4; //~ ERROR cannot assign
     }
 }
-
diff --git a/src/test/compile-fail/borrowck-ref-into-rvalue.rs b/src/test/compile-fail/borrowck-ref-into-rvalue.rs
index 18865ad7d54..7026f06c2b7 100644
--- a/src/test/compile-fail/borrowck-ref-into-rvalue.rs
+++ b/src/test/compile-fail/borrowck-ref-into-rvalue.rs
@@ -18,4 +18,3 @@ fn main() {
     }
     io::println(*msg);
 }
-
diff --git a/src/test/compile-fail/borrowck-vec-pattern-loan-from-mut.rs b/src/test/compile-fail/borrowck-vec-pattern-loan-from-mut.rs
index 6b51fc8f5b3..635ce77bb8a 100644
--- a/src/test/compile-fail/borrowck-vec-pattern-loan-from-mut.rs
+++ b/src/test/compile-fail/borrowck-vec-pattern-loan-from-mut.rs
@@ -9,4 +9,3 @@ fn a() {
 }
 
 fn main() {}
-
diff --git a/src/test/compile-fail/borrowck-vec-pattern-nesting.rs b/src/test/compile-fail/borrowck-vec-pattern-nesting.rs
index 16711ea61ff..941455d086c 100644
--- a/src/test/compile-fail/borrowck-vec-pattern-nesting.rs
+++ b/src/test/compile-fail/borrowck-vec-pattern-nesting.rs
@@ -18,4 +18,3 @@ fn b() {
 }
 
 fn main() {}
-
diff --git a/src/test/compile-fail/borrowck-wg-borrow-mut-to-imm-fail-2.rs b/src/test/compile-fail/borrowck-wg-borrow-mut-to-imm-fail-2.rs
index 5ef23897ec0..451f023f5fc 100644
--- a/src/test/compile-fail/borrowck-wg-borrow-mut-to-imm-fail-2.rs
+++ b/src/test/compile-fail/borrowck-wg-borrow-mut-to-imm-fail-2.rs
@@ -3,4 +3,3 @@ fn main() {
     let _x = &mut *b;
     let _y = &mut *b; //~ ERROR cannot borrow
 }
-
diff --git a/src/test/compile-fail/borrowck-wg-borrow-mut-to-imm-fail-3.rs b/src/test/compile-fail/borrowck-wg-borrow-mut-to-imm-fail-3.rs
index a744127a600..c455de888a3 100644
--- a/src/test/compile-fail/borrowck-wg-borrow-mut-to-imm-fail-3.rs
+++ b/src/test/compile-fail/borrowck-wg-borrow-mut-to-imm-fail-3.rs
@@ -5,4 +5,3 @@ fn main() {
     let mut d = /*move*/ a; //~ ERROR cannot move out
     *d += 1;
 }
-
diff --git a/src/test/compile-fail/borrowck-wg-borrow-mut-to-imm-fail.rs b/src/test/compile-fail/borrowck-wg-borrow-mut-to-imm-fail.rs
index 44da00d8d17..e18808dfe53 100644
--- a/src/test/compile-fail/borrowck-wg-borrow-mut-to-imm-fail.rs
+++ b/src/test/compile-fail/borrowck-wg-borrow-mut-to-imm-fail.rs
@@ -4,4 +4,3 @@ fn main() {
     let mut y = /*move*/ b; //~ ERROR cannot move out
     *y += 1;
 }
-
diff --git a/src/test/compile-fail/borrowck-wg-move-base-2.rs b/src/test/compile-fail/borrowck-wg-move-base-2.rs
index 8a218771453..4050b4c5971 100644
--- a/src/test/compile-fail/borrowck-wg-move-base-2.rs
+++ b/src/test/compile-fail/borrowck-wg-move-base-2.rs
@@ -7,5 +7,3 @@ fn foo(x: &mut int) {
 
 fn main() {
 }
-
-
diff --git a/src/test/compile-fail/by-move-pattern-binding.rs b/src/test/compile-fail/by-move-pattern-binding.rs
index 95091f15ce0..1efed154286 100644
--- a/src/test/compile-fail/by-move-pattern-binding.rs
+++ b/src/test/compile-fail/by-move-pattern-binding.rs
@@ -20,4 +20,3 @@ fn main() {
         &Bar(ref identifier) => io::println(*identifier)
     };
 }
-    
diff --git a/src/test/compile-fail/dead-code-ret.rs b/src/test/compile-fail/dead-code-ret.rs
index 182a41c1b17..97f6149b162 100644
--- a/src/test/compile-fail/dead-code-ret.rs
+++ b/src/test/compile-fail/dead-code-ret.rs
@@ -15,4 +15,3 @@
 fn f(caller: str) { debug!(caller); }
 
 fn main() { return f("main"); debug!("Paul is dead"); }
-
diff --git a/src/test/compile-fail/does-nothing.rs b/src/test/compile-fail/does-nothing.rs
index a360d657957..699baad4d43 100644
--- a/src/test/compile-fail/does-nothing.rs
+++ b/src/test/compile-fail/does-nothing.rs
@@ -1,3 +1,2 @@
 // error-pattern: unresolved name: `this_does_nothing_what_the`.
 fn main() { debug!("doing"); this_does_nothing_what_the; debug!("boing"); }
-
diff --git a/src/test/compile-fail/drop-on-non-struct.rs b/src/test/compile-fail/drop-on-non-struct.rs
index 4e5b64c8f3d..b2f87686ac6 100644
--- a/src/test/compile-fail/drop-on-non-struct.rs
+++ b/src/test/compile-fail/drop-on-non-struct.rs
@@ -19,5 +19,3 @@ impl Drop for Foo {   //~ ERROR the Drop trait may only be implemented
 
 fn main() {
 }
-
-
diff --git a/src/test/compile-fail/eval-enum.rs b/src/test/compile-fail/eval-enum.rs
index 01233419579..f92dad961d1 100644
--- a/src/test/compile-fail/eval-enum.rs
+++ b/src/test/compile-fail/eval-enum.rs
@@ -1,5 +1,5 @@
 enum test {
-    quot_zero = 1/0, //~ERROR expected constant: attempted quotient with a divisor of zero
+    div_zero = 1/0, //~ERROR expected constant: attempted to divide by zero
     rem_zero = 1%0  //~ERROR expected constant: attempted remainder with a divisor of zero
 }
 
diff --git a/src/test/compile-fail/explicit-call-to-dtor.rs b/src/test/compile-fail/explicit-call-to-dtor.rs
index 71674186b61..24fedaaabe3 100644
--- a/src/test/compile-fail/explicit-call-to-dtor.rs
+++ b/src/test/compile-fail/explicit-call-to-dtor.rs
@@ -22,4 +22,3 @@ fn main() {
     let x = Foo { x: 3 };
     x.finalize();   //~ ERROR explicit call to destructor
 }
-
diff --git a/src/test/compile-fail/explicit-call-to-supertrait-dtor.rs b/src/test/compile-fail/explicit-call-to-supertrait-dtor.rs
index 26b13566f7a..fd49889a3f7 100644
--- a/src/test/compile-fail/explicit-call-to-supertrait-dtor.rs
+++ b/src/test/compile-fail/explicit-call-to-supertrait-dtor.rs
@@ -31,5 +31,3 @@ impl Bar for Foo {
 fn main() {
     let x = Foo { x: 3 };
 }
-
-
diff --git a/src/test/compile-fail/float-literal-inference-restrictions.rs b/src/test/compile-fail/float-literal-inference-restrictions.rs
index 80aefbbf48f..48dbdd86b11 100644
--- a/src/test/compile-fail/float-literal-inference-restrictions.rs
+++ b/src/test/compile-fail/float-literal-inference-restrictions.rs
@@ -12,4 +12,3 @@ fn main() {
     let x: f32 = 1; //~ ERROR mismatched types
     let y: f32 = 1f; //~ ERROR mismatched types
 }
-
diff --git a/src/test/compile-fail/foreign-unsafe-fn-called.rs b/src/test/compile-fail/foreign-unsafe-fn-called.rs
index 9122abab713..ed8b8088ee4 100644
--- a/src/test/compile-fail/foreign-unsafe-fn-called.rs
+++ b/src/test/compile-fail/foreign-unsafe-fn-called.rs
@@ -21,4 +21,3 @@ fn main() {
     test::free();
     //~^ ERROR access to unsafe function requires unsafe function or block
 }
-
diff --git a/src/test/compile-fail/foreign-unsafe-fn.rs b/src/test/compile-fail/foreign-unsafe-fn.rs
index 32fafe29646..3633267d02c 100644
--- a/src/test/compile-fail/foreign-unsafe-fn.rs
+++ b/src/test/compile-fail/foreign-unsafe-fn.rs
@@ -21,5 +21,3 @@ fn main() {
     let x = test::free;
     //~^ ERROR access to unsafe function requires unsafe function or block
 }
-
-
diff --git a/src/test/compile-fail/issue-1451.rs b/src/test/compile-fail/issue-1451.rs
index acc371076e7..a295e8eb7ed 100644
--- a/src/test/compile-fail/issue-1451.rs
+++ b/src/test/compile-fail/issue-1451.rs
@@ -30,4 +30,3 @@ fn main() {
     fooT(T {f: x});
     fooT(T {f: bar});
 }
-
diff --git a/src/test/compile-fail/issue-2951.rs b/src/test/compile-fail/issue-2951.rs
index 3874d9b13f5..e57d4f09175 100644
--- a/src/test/compile-fail/issue-2951.rs
+++ b/src/test/compile-fail/issue-2951.rs
@@ -15,5 +15,4 @@ fn foo<T, U>(x: T, y: U) {
 }
 
 fn main() {
-    
 }
diff --git a/src/test/compile-fail/issue-3044.rs b/src/test/compile-fail/issue-3044.rs
index 23b11bbe409..06fb18d7e47 100644
--- a/src/test/compile-fail/issue-3044.rs
+++ b/src/test/compile-fail/issue-3044.rs
@@ -16,4 +16,3 @@ fn main() {
     //
     // the first error is, um, non-ideal.
 }
-
diff --git a/src/test/compile-fail/issue-3096-2.rs b/src/test/compile-fail/issue-3096-2.rs
index da13d450273..eb58cf3e13b 100644
--- a/src/test/compile-fail/issue-3096-2.rs
+++ b/src/test/compile-fail/issue-3096-2.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-enum bottom { } 
+enum bottom { }
 
 fn main() {
     let x = ptr::to_unsafe_ptr(&()) as *bottom;
diff --git a/src/test/compile-fail/issue-3991.rs b/src/test/compile-fail/issue-3991.rs
index d1c9057b880..d3016f893b4 100644
--- a/src/test/compile-fail/issue-3991.rs
+++ b/src/test/compile-fail/issue-3991.rs
@@ -12,11 +12,11 @@
 struct HasNested {
     mut nest: ~[~[int]],
 }
-    
+
 impl HasNested {
     fn method_push_local(&self) {
         self.nest[0].push(0);
     }
 }
-    
+
 fn main() {}
diff --git a/src/test/compile-fail/issue-4265.rs b/src/test/compile-fail/issue-4265.rs
index b6a32f5feba..e76d211deda 100644
--- a/src/test/compile-fail/issue-4265.rs
+++ b/src/test/compile-fail/issue-4265.rs
@@ -11,12 +11,12 @@
 struct Foo {
       baz: uint
 }
-    
+
 impl Foo {
     fn bar() {
         Foo { baz: 0 }.bar();
     }
-    
+
     fn bar() { //~ ERROR duplicate definition of value bar
     }
 }
diff --git a/src/test/compile-fail/issue-4366.rs b/src/test/compile-fail/issue-4366.rs
index 7d97932d9af..f4e57171599 100644
--- a/src/test/compile-fail/issue-4366.rs
+++ b/src/test/compile-fail/issue-4366.rs
@@ -37,4 +37,3 @@ mod m1 {
 fn main() {
     foo(); //~ ERROR: unresolved name: `foo`
 }
-
diff --git a/src/test/compile-fail/issue-4968.rs b/src/test/compile-fail/issue-4968.rs
index fc0c29e9a79..700d8a61c3a 100644
--- a/src/test/compile-fail/issue-4968.rs
+++ b/src/test/compile-fail/issue-4968.rs
@@ -14,4 +14,3 @@ static A: (int,int) = (4,2);
 fn main() {
     match 42 { A => () } //~ ERROR mismatched types: expected `<VI0>` but found `(int,int)` (expected integral variable but found tuple)
 }
-
diff --git a/src/test/compile-fail/issue-5100.rs b/src/test/compile-fail/issue-5100.rs
new file mode 100644
index 00000000000..dbfdb38f721
--- /dev/null
+++ b/src/test/compile-fail/issue-5100.rs
@@ -0,0 +1,44 @@
+// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+enum A { B, C }
+
+fn main() {
+    match (true, false) {
+        B => (), //~ ERROR expected `(bool,bool)` but found an enum or structure pattern
+        _ => ()
+    }
+
+    match (true, false) {
+        (true, false, false) => () //~ ERROR mismatched types: expected `(bool,bool)` but found `(bool,bool,bool)` (expected a tuple with 2 elements but found one with 3 elements)
+    }
+
+    match (true, false) {
+        @(true, false) => () //~ ERROR mismatched types: expected `(bool,bool)` but found an @-box pattern
+    }
+
+    match (true, false) {
+        ~(true, false) => () //~ ERROR mismatched types: expected `(bool,bool)` but found a ~-box pattern
+    }
+
+    match (true, false) {
+        &(true, false) => () //~ ERROR mismatched types: expected `(bool,bool)` but found an &-pointer pattern
+    }
+
+
+    let v = [('a', 'b')   //~ ERROR expected function but found `(char,char)`
+             ('c', 'd'),
+             ('e', 'f')];
+
+    for v.each |&(x,y)| {} // should be OK
+
+    // Make sure none of the errors above were fatal
+    let x: char = true; //~ ERROR expected `char` but found `bool`
+}
diff --git a/src/test/run-pass/issue-1466.rs b/src/test/compile-fail/issue-5358-1.rs
index 1915f1b3a41..0b6e2fb0ff5 100644
--- a/src/test/run-pass/issue-1466.rs
+++ b/src/test/compile-fail/issue-5358-1.rs
@@ -1,4 +1,4 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
 //
@@ -8,10 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// exec-env:RUST_CC_ZEAL=1
-// xfail-test
+struct S(Either<uint, uint>);
 
-pub fn main() {
-    error!("%?", os::getenv(~"RUST_CC_ZEAL"));
-    let _x = @{a: @10, b: ~true};
+fn main() {
+    match S(Left(5)) {
+        Right(_) => {}  //~ ERROR mismatched types: expected `S` but found `core::either::Either
+        _ => {}
+    }
 }
diff --git a/src/test/auxiliary/issue-2196-b.rs b/src/test/compile-fail/issue-5358.rs
index 1ef9334b7cd..7d11a127f9a 100644
--- a/src/test/auxiliary/issue-2196-b.rs
+++ b/src/test/compile-fail/issue-5358.rs
@@ -1,4 +1,4 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
 //
@@ -8,11 +8,10 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#[link(name = "issue2196b", vers = "0.1")];
-#[crate_type = "lib"];
-
-use a(name = "issue2196a");
-
-type d = str;
-impl d for d { }
+struct S(Either<uint, uint>);
 
+fn main() {
+    match *S(Left(5)) {
+      S(_) => {}  //~ ERROR mismatched types: expected `core::either::Either<uint,uint>` but found a structure pattern
+    }
+}
diff --git a/src/test/auxiliary/issue-2196-a.rs b/src/test/compile-fail/issue-5927.rs
index 959164d85dd..a1b4ee7aa34 100644
--- a/src/test/auxiliary/issue-2196-a.rs
+++ b/src/test/compile-fail/issue-5927.rs
@@ -1,4 +1,4 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
 //
@@ -8,6 +8,13 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#[link(name = "issue2196a", vers = "0.1")];
-#[crate_type = "lib"];
 
+
+// error-pattern:unresolved enum variant
+
+fn main() {
+    let z = match 3 {
+        x() => x
+    };
+    assert_eq!(z,3);
+}
diff --git a/src/test/compile-fail/kindck-destructor-owned.rs b/src/test/compile-fail/kindck-destructor-owned.rs
index e956f95b422..faad36a15d2 100644
--- a/src/test/compile-fail/kindck-destructor-owned.rs
+++ b/src/test/compile-fail/kindck-destructor-owned.rs
@@ -9,4 +9,3 @@ impl Drop for Foo { //~ ERROR cannot implement a destructor on a struct that is
 }
 
 fn main() { }
-
diff --git a/src/test/compile-fail/lint-default-methods.rs b/src/test/compile-fail/lint-default-methods.rs
index 1350c3e3ad1..89b99fcebca 100644
--- a/src/test/compile-fail/lint-default-methods.rs
+++ b/src/test/compile-fail/lint-default-methods.rs
@@ -5,4 +5,3 @@ trait Foo { //~ ERROR default methods are experimental
 }
 
 fn main() {}
-
diff --git a/src/test/compile-fail/lint-type-limits.rs b/src/test/compile-fail/lint-type-limits.rs
index e45ef38e97a..2eb794fd1c2 100644
--- a/src/test/compile-fail/lint-type-limits.rs
+++ b/src/test/compile-fail/lint-type-limits.rs
@@ -32,4 +32,3 @@ fn qux() {
         i += 1;
     }
 }
-
diff --git a/src/test/compile-fail/liveness-if-no-else.rs b/src/test/compile-fail/liveness-if-no-else.rs
index e37ee5bd4d4..22b1b5edbac 100644
--- a/src/test/compile-fail/liveness-if-no-else.rs
+++ b/src/test/compile-fail/liveness-if-no-else.rs
@@ -11,6 +11,6 @@
 fn foo(x: int) { debug!(x); }
 
 fn main() {
-	let x: int; if 1 > 2 { x = 10; }
-	foo(x); //~ ERROR use of possibly uninitialized variable: `x`
+    let x: int; if 1 > 2 { x = 10; }
+    foo(x); //~ ERROR use of possibly uninitialized variable: `x`
 }
diff --git a/src/test/compile-fail/liveness-return.rs b/src/test/compile-fail/liveness-return.rs
index 12f7aa434cc..6558bc57968 100644
--- a/src/test/compile-fail/liveness-return.rs
+++ b/src/test/compile-fail/liveness-return.rs
@@ -9,8 +9,8 @@
 // except according to those terms.
 
 fn f() -> int {
-	let x: int;
-	return x; //~ ERROR use of possibly uninitialized variable: `x`
+    let x: int;
+    return x; //~ ERROR use of possibly uninitialized variable: `x`
 }
 
 fn main() { f(); }
diff --git a/src/test/compile-fail/liveness-uninit-after-item.rs b/src/test/compile-fail/liveness-uninit-after-item.rs
index b3ab0053888..a828b1d6b9f 100644
--- a/src/test/compile-fail/liveness-uninit-after-item.rs
+++ b/src/test/compile-fail/liveness-uninit-after-item.rs
@@ -13,4 +13,3 @@ fn main() {
     fn baz(_x: int) { }
     baz(bar); //~ ERROR use of possibly uninitialized variable: `bar`
 }
-
diff --git a/src/test/compile-fail/liveness-uninit.rs b/src/test/compile-fail/liveness-uninit.rs
index 8797132fd50..a360f8e85a6 100644
--- a/src/test/compile-fail/liveness-uninit.rs
+++ b/src/test/compile-fail/liveness-uninit.rs
@@ -11,6 +11,6 @@
 fn foo(x: int) { debug!(x); }
 
 fn main() {
-	let x: int;
-	foo(x); //~ ERROR use of possibly uninitialized variable: `x`
+    let x: int;
+    foo(x); //~ ERROR use of possibly uninitialized variable: `x`
 }
diff --git a/src/test/compile-fail/macro-with-seps-err-msg.rs b/src/test/compile-fail/macro-with-seps-err-msg.rs
index 74c040238ac..95250e36b86 100644
--- a/src/test/compile-fail/macro-with-seps-err-msg.rs
+++ b/src/test/compile-fail/macro-with-seps-err-msg.rs
@@ -13,5 +13,3 @@
 fn main() {
     globnar::brotz!();
 }
-
-
diff --git a/src/test/compile-fail/missing-derivable-attr.rs b/src/test/compile-fail/missing-derivable-attr.rs
index 67cf67bfa5a..eb27d51061f 100644
--- a/src/test/compile-fail/missing-derivable-attr.rs
+++ b/src/test/compile-fail/missing-derivable-attr.rs
@@ -24,4 +24,3 @@ impl MyEq for A;  //~ ERROR missing method
 
 fn main() {
 }
-
diff --git a/src/test/compile-fail/missing-return.rs b/src/test/compile-fail/missing-return.rs
index c0007d2bee8..1dc817cc6e6 100644
--- a/src/test/compile-fail/missing-return.rs
+++ b/src/test/compile-fail/missing-return.rs
@@ -13,4 +13,3 @@
 fn f() -> int { }
 
 fn main() { f(); }
-
diff --git a/src/test/compile-fail/moves-based-on-type-block-bad.rs b/src/test/compile-fail/moves-based-on-type-block-bad.rs
index feeaadeea82..76d50710bb8 100644
--- a/src/test/compile-fail/moves-based-on-type-block-bad.rs
+++ b/src/test/compile-fail/moves-based-on-type-block-bad.rs
@@ -24,4 +24,3 @@ fn main() {
         }
     }
 }
-
diff --git a/src/test/compile-fail/moves-based-on-type-capture-clause-bad.rs b/src/test/compile-fail/moves-based-on-type-capture-clause-bad.rs
index 57829e72674..6dce011ddc8 100644
--- a/src/test/compile-fail/moves-based-on-type-capture-clause-bad.rs
+++ b/src/test/compile-fail/moves-based-on-type-capture-clause-bad.rs
@@ -5,4 +5,3 @@ fn main() {
     }
     io::println(x); //~ ERROR use of moved value
 }
-
diff --git a/src/test/compile-fail/moves-based-on-type-cyclic-types-issue-4821.rs b/src/test/compile-fail/moves-based-on-type-cyclic-types-issue-4821.rs
index bee9596df72..2b9291ce328 100644
--- a/src/test/compile-fail/moves-based-on-type-cyclic-types-issue-4821.rs
+++ b/src/test/compile-fail/moves-based-on-type-cyclic-types-issue-4821.rs
@@ -29,4 +29,3 @@ fn consume(v: ~List) -> int {
 }
 
 fn main() {}
-
diff --git a/src/test/compile-fail/no-capture-arc.rs b/src/test/compile-fail/no-capture-arc.rs
index da75dfd0106..2c8c98ad5d6 100644
--- a/src/test/compile-fail/no-capture-arc.rs
+++ b/src/test/compile-fail/no-capture-arc.rs
@@ -16,7 +16,7 @@ use std::arc;
 fn main() {
     let v = ~[1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
     let arc_v = arc::ARC(v);
-    
+
     do task::spawn() {
         let v = *arc::get(&arc_v);
         assert!(v[3] == 4);
diff --git a/src/test/compile-fail/noexporttypeexe.rs b/src/test/compile-fail/noexporttypeexe.rs
index 8d9796c7c41..95428568e4c 100644
--- a/src/test/compile-fail/noexporttypeexe.rs
+++ b/src/test/compile-fail/noexporttypeexe.rs
@@ -20,4 +20,3 @@ fn main() {
   let x: int = noexporttypelib::foo();
     //~^ ERROR expected `int` but found `core::option::Option<int>`
 }
-
diff --git a/src/test/compile-fail/non-exhaustive-match-nested.rs b/src/test/compile-fail/non-exhaustive-match-nested.rs
index 4d1db362376..34fe6b0f678 100644
--- a/src/test/compile-fail/non-exhaustive-match-nested.rs
+++ b/src/test/compile-fail/non-exhaustive-match-nested.rs
@@ -20,4 +20,3 @@ fn main() {
       b => { fail!(~"goodbye"); }
     }
 }
-
diff --git a/src/test/compile-fail/once-fn-subtyping.rs b/src/test/compile-fail/once-fn-subtyping.rs
index 00009c706e3..178c04dfc79 100644
--- a/src/test/compile-fail/once-fn-subtyping.rs
+++ b/src/test/compile-fail/once-fn-subtyping.rs
@@ -14,4 +14,3 @@ fn main() {
     let h: &fn() = ||();
     let i: &once fn() = h;  // ok
 }
-
diff --git a/src/test/compile-fail/private-impl-method.rs b/src/test/compile-fail/private-impl-method.rs
index 74bdcdc7f82..a6728f82ec3 100644
--- a/src/test/compile-fail/private-impl-method.rs
+++ b/src/test/compile-fail/private-impl-method.rs
@@ -22,4 +22,3 @@ fn main() {
     let s = a::Foo { x: 1 };
     s.foo();    //~ ERROR method `foo` is private
 }
-
diff --git a/src/test/compile-fail/private-item-simple.rs b/src/test/compile-fail/private-item-simple.rs
index e8038df188b..8776739db2d 100644
--- a/src/test/compile-fail/private-item-simple.rs
+++ b/src/test/compile-fail/private-item-simple.rs
@@ -15,4 +15,3 @@ mod a {
 fn main() {
     a::f(); //~ ERROR unresolved name
 }
-
diff --git a/src/test/compile-fail/private-method-inherited.rs b/src/test/compile-fail/private-method-inherited.rs
index 7b64623e16c..bc27027e886 100644
--- a/src/test/compile-fail/private-method-inherited.rs
+++ b/src/test/compile-fail/private-method-inherited.rs
@@ -12,4 +12,3 @@ fn main() {
     let x = a::Foo;
     x.f();  //~ ERROR method `f` is private
 }
-
diff --git a/src/test/compile-fail/private-struct-field-ctor.rs b/src/test/compile-fail/private-struct-field-ctor.rs
index 43e7427dd74..7ab28d72965 100644
--- a/src/test/compile-fail/private-struct-field-ctor.rs
+++ b/src/test/compile-fail/private-struct-field-ctor.rs
@@ -17,4 +17,3 @@ mod a {
 fn main() {
     let s = a::Foo { x: 1 };    //~ ERROR field `x` is private
 }
-
diff --git a/src/test/compile-fail/private-struct-field-pattern.rs b/src/test/compile-fail/private-struct-field-pattern.rs
index 864c9bd98d7..6f524a8eaa4 100644
--- a/src/test/compile-fail/private-struct-field-pattern.rs
+++ b/src/test/compile-fail/private-struct-field-pattern.rs
@@ -25,4 +25,3 @@ fn main() {
         Foo { x: _ } => {}  //~ ERROR field `x` is private
     }
 }
-
diff --git a/src/test/compile-fail/qquote-1.rs b/src/test/compile-fail/qquote-1.rs
index eda207f711d..4710d9dee45 100644
--- a/src/test/compile-fail/qquote-1.rs
+++ b/src/test/compile-fail/qquote-1.rs
@@ -65,4 +65,3 @@ fn main() {
 fn check_pp<T>(expr: T, f: &fn(pprust::ps, T), expect: str) {
     fail!();
 }
-
diff --git a/src/test/compile-fail/qquote-2.rs b/src/test/compile-fail/qquote-2.rs
index c6690534008..d3773256105 100644
--- a/src/test/compile-fail/qquote-2.rs
+++ b/src/test/compile-fail/qquote-2.rs
@@ -60,4 +60,3 @@ fn main() {
 fn check_pp<T>(expr: T, f: &fn(pprust::ps, T), expect: str) {
     fail!();
 }
-
diff --git a/src/test/compile-fail/refutable-pattern-in-fn-arg.rs b/src/test/compile-fail/refutable-pattern-in-fn-arg.rs
index 5e157c1bd7b..957925709e1 100644
--- a/src/test/compile-fail/refutable-pattern-in-fn-arg.rs
+++ b/src/test/compile-fail/refutable-pattern-in-fn-arg.rs
@@ -12,4 +12,3 @@ fn main() {
     let f = |3: int| io::println("hello");  //~ ERROR refutable pattern
     f(4);
 }
-
diff --git a/src/test/compile-fail/regions-addr-of-self.rs b/src/test/compile-fail/regions-addr-of-self.rs
index 732d946bf9e..f96ef639e75 100644
--- a/src/test/compile-fail/regions-addr-of-self.rs
+++ b/src/test/compile-fail/regions-addr-of-self.rs
@@ -35,4 +35,3 @@ fn main() {
     d.chase_cat();
     debug!("cats_chased: %u", d.cats_chased);
 }
-
diff --git a/src/test/compile-fail/regions-infer-borrow-scope-too-big.rs b/src/test/compile-fail/regions-infer-borrow-scope-too-big.rs
index 6e9d6c1ef0f..d519397f68c 100644
--- a/src/test/compile-fail/regions-infer-borrow-scope-too-big.rs
+++ b/src/test/compile-fail/regions-infer-borrow-scope-too-big.rs
@@ -24,4 +24,3 @@ fn foo(p: @point) -> &int {
 }
 
 fn main() {}
-
diff --git a/src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs b/src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs
index d23e20130f7..50ac5f65772 100644
--- a/src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs
+++ b/src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs
@@ -15,8 +15,8 @@ fn foo(cond: &fn() -> bool, box: &fn() -> @int) {
     loop {
         let x = box();
 
-	// Here we complain because the resulting region
-	// of this borrow is the fn body as a whole.
+	    // Here we complain because the resulting region
+	    // of this borrow is the fn body as a whole.
         y = borrow(x); //~ ERROR cannot root
 
         assert!(*x == *y);
diff --git a/src/test/compile-fail/regions-ret.rs b/src/test/compile-fail/regions-ret.rs
index f1a7bdf2281..eccffb4051e 100644
--- a/src/test/compile-fail/regions-ret.rs
+++ b/src/test/compile-fail/regions-ret.rs
@@ -14,4 +14,3 @@ fn f<'a>(_x : &'a int) -> &'a int {
 
 fn main() {
 }
-
diff --git a/src/test/compile-fail/repeat-to-run-dtor-twice.rs b/src/test/compile-fail/repeat-to-run-dtor-twice.rs
index 18bdb564441..e1e1e2313f4 100644
--- a/src/test/compile-fail/repeat-to-run-dtor-twice.rs
+++ b/src/test/compile-fail/repeat-to-run-dtor-twice.rs
@@ -26,4 +26,3 @@ fn main() {
     let a = Foo { x: 3 };
     let _ = [ a, ..5 ];     //~ ERROR copying a value of non-copyable type
 }
-
diff --git a/src/test/compile-fail/static-method-privacy.rs b/src/test/compile-fail/static-method-privacy.rs
index 50df4f04971..0fd82b5ace3 100644
--- a/src/test/compile-fail/static-method-privacy.rs
+++ b/src/test/compile-fail/static-method-privacy.rs
@@ -8,4 +8,3 @@ mod a {
 fn main() {
     let _ = a::S::new();    //~ ERROR function `new` is private
 }
-
diff --git a/src/test/compile-fail/static-region-bound.rs b/src/test/compile-fail/static-region-bound.rs
index 500a5b0c8bc..ada3aebb2f4 100644
--- a/src/test/compile-fail/static-region-bound.rs
+++ b/src/test/compile-fail/static-region-bound.rs
@@ -6,4 +6,3 @@ fn main() {
     let x = &3;
     f(x);   //~ ERROR instantiating a type parameter with an incompatible type
 }
-
diff --git a/src/test/compile-fail/struct-like-enum-nonexhaustive.rs b/src/test/compile-fail/struct-like-enum-nonexhaustive.rs
index 52a61628c35..91709e2ea7d 100644
--- a/src/test/compile-fail/struct-like-enum-nonexhaustive.rs
+++ b/src/test/compile-fail/struct-like-enum-nonexhaustive.rs
@@ -20,5 +20,3 @@ fn main() {
         B { x: None } => {}
     }
 }
-
-
diff --git a/src/test/compile-fail/super-at-top-level.rs b/src/test/compile-fail/super-at-top-level.rs
index 21b9e5292b1..f1064a62905 100644
--- a/src/test/compile-fail/super-at-top-level.rs
+++ b/src/test/compile-fail/super-at-top-level.rs
@@ -2,6 +2,4 @@ use super::f;   //~ ERROR unresolved name
 //~^ ERROR failed to resolve import
 
 fn main() {
-    
 }
-
diff --git a/src/test/compile-fail/trait-impl-method-mismatch.rs b/src/test/compile-fail/trait-impl-method-mismatch.rs
index 7f4c227d2d0..54fa62f7977 100644
--- a/src/test/compile-fail/trait-impl-method-mismatch.rs
+++ b/src/test/compile-fail/trait-impl-method-mismatch.rs
@@ -19,7 +19,3 @@ impl Mumbo for uint {
 }
 
 fn main() {}
-
-
-
-
diff --git a/src/test/compile-fail/trait-inheritance-missing-requirement.rs b/src/test/compile-fail/trait-inheritance-missing-requirement.rs
index a341c242611..5968c296e13 100644
--- a/src/test/compile-fail/trait-inheritance-missing-requirement.rs
+++ b/src/test/compile-fail/trait-inheritance-missing-requirement.rs
@@ -30,4 +30,3 @@ impl Bar for A {
 
 fn main() {
 }
-
diff --git a/src/test/compile-fail/tuple-struct-nonexhaustive.rs b/src/test/compile-fail/tuple-struct-nonexhaustive.rs
index 7cfdab2e96d..de28a06abab 100644
--- a/src/test/compile-fail/tuple-struct-nonexhaustive.rs
+++ b/src/test/compile-fail/tuple-struct-nonexhaustive.rs
@@ -17,5 +17,3 @@ fn main() {
         Foo(2, b) => io::println(fmt!("%d", b))
     }
 }
-
-
diff --git a/src/test/compile-fail/tutorial-suffix-inference-test.rs b/src/test/compile-fail/tutorial-suffix-inference-test.rs
index c68af84b95b..d92aa8d640a 100644
--- a/src/test/compile-fail/tutorial-suffix-inference-test.rs
+++ b/src/test/compile-fail/tutorial-suffix-inference-test.rs
@@ -22,11 +22,11 @@ fn main() {
     //~^ ERROR mismatched types: expected `u16` but found `i32`
 
     let a = 3i;
-    
+
     fn identity_i(n: int) -> int { n }
 
     identity_i(a); // ok
-    identity_u16(a); 
+    identity_u16(a);
     //~^ ERROR mismatched types: expected `u16` but found `int`
 
 }
diff --git a/src/test/compile-fail/uninhabited-enum-cast.rs b/src/test/compile-fail/uninhabited-enum-cast.rs
new file mode 100644
index 00000000000..c4a5dc4710c
--- /dev/null
+++ b/src/test/compile-fail/uninhabited-enum-cast.rs
@@ -0,0 +1,7 @@
+enum E {}
+
+fn f(e: E) {
+    println((e as int).to_str());   //~ ERROR non-scalar cast
+}
+
+fn main() {}
diff --git a/src/test/compile-fail/unique-object-noncopyable.rs b/src/test/compile-fail/unique-object-noncopyable.rs
index edc8a47822d..95945b0b5ba 100644
--- a/src/test/compile-fail/unique-object-noncopyable.rs
+++ b/src/test/compile-fail/unique-object-noncopyable.rs
@@ -31,4 +31,3 @@ fn main() {
     let y: ~Foo = x as ~Foo;
     let _z = copy y; //~ ERROR copying a value of non-copyable type
 }
-
diff --git a/src/test/compile-fail/use-after-move-based-on-type.rs b/src/test/compile-fail/use-after-move-based-on-type.rs
index 6c268c5e13c..3d176bb339d 100644
--- a/src/test/compile-fail/use-after-move-based-on-type.rs
+++ b/src/test/compile-fail/use-after-move-based-on-type.rs
@@ -13,4 +13,3 @@ fn main() {
     let _y = x;
     io::println(x); //~ ERROR use of moved value
 }
-
diff --git a/src/test/compile-fail/use-after-move-self-based-on-type.rs b/src/test/compile-fail/use-after-move-self-based-on-type.rs
index b0a2bc8ec12..627b8924b67 100644
--- a/src/test/compile-fail/use-after-move-self-based-on-type.rs
+++ b/src/test/compile-fail/use-after-move-self-based-on-type.rs
@@ -19,4 +19,3 @@ fn main() {
     let x = S { x: 1 };
     io::println(x.foo().to_str());
 }
-
diff --git a/src/test/compile-fail/use-after-move-self.rs b/src/test/compile-fail/use-after-move-self.rs
index 3eded9fd4f3..11f37df4541 100644
--- a/src/test/compile-fail/use-after-move-self.rs
+++ b/src/test/compile-fail/use-after-move-self.rs
@@ -15,4 +15,3 @@ fn main() {
     let x = S { x: ~1 };
     io::println(x.foo().to_str());
 }
-
diff --git a/src/test/compile-fail/view-items-at-top.rs b/src/test/compile-fail/view-items-at-top.rs
index a637836320d..023be703cca 100644
--- a/src/test/compile-fail/view-items-at-top.rs
+++ b/src/test/compile-fail/view-items-at-top.rs
@@ -19,4 +19,3 @@ use std::net;    //~ ERROR view items must be declared at the top
 
 fn main() {
 }
-
diff --git a/src/test/compile-fail/while-type-error.rs b/src/test/compile-fail/while-type-error.rs
index f9d3dce7508..ecab746373a 100644
--- a/src/test/compile-fail/while-type-error.rs
+++ b/src/test/compile-fail/while-type-error.rs
@@ -11,4 +11,3 @@
 // error-pattern: mismatched types
 
 fn main() { while main { } }
-
diff --git a/src/test/compile-fail/xc-private-method.rs b/src/test/compile-fail/xc-private-method.rs
index d194820df94..e8777a0a9f2 100644
--- a/src/test/compile-fail/xc-private-method.rs
+++ b/src/test/compile-fail/xc-private-method.rs
@@ -6,4 +6,3 @@ extern mod xc_private_method_lib;
 fn main() {
     let _ = xc_private_method_lib::Foo::new();  //~ ERROR function `new` is private
 }
-
diff --git a/src/test/pretty/doc-comments.rs b/src/test/pretty/doc-comments.rs
index a866afd2405..45e242c0ca0 100644
--- a/src/test/pretty/doc-comments.rs
+++ b/src/test/pretty/doc-comments.rs
@@ -22,7 +22,7 @@ fn b() {
 //////////////////////////////////
 // some single-line non-doc comment preceded by a separator
 
-//////////////////////////////////           
+//////////////////////////////////
 /// some single-line outer-docs preceded by a separator
 /// (and trailing whitespaces)
 fn c() { }
diff --git a/src/test/run-fail/assert-as-macro.rs b/src/test/run-fail/assert-as-macro.rs
index 07813b91e57..f715e21f781 100644
--- a/src/test/run-fail/assert-as-macro.rs
+++ b/src/test/run-fail/assert-as-macro.rs
@@ -3,4 +3,3 @@
 fn main() {
     assert!(1 == 2);
 }
-
diff --git a/src/test/run-fail/borrowck-wg-fail-3.rs b/src/test/run-fail/borrowck-wg-fail-3.rs
index ebff553aafb..a40faa1ac6f 100644
--- a/src/test/run-fail/borrowck-wg-fail-3.rs
+++ b/src/test/run-fail/borrowck-wg-fail-3.rs
@@ -9,4 +9,3 @@ fn main() {
     let z = x;
     *z = 5;
 }
-
diff --git a/src/test/run-fail/borrowck-wg-fail.rs b/src/test/run-fail/borrowck-wg-fail.rs
index 939d802c21c..201db14eb17 100644
--- a/src/test/run-fail/borrowck-wg-fail.rs
+++ b/src/test/run-fail/borrowck-wg-fail.rs
@@ -11,4 +11,3 @@ fn main() {
     let x = @mut 3;
     f(x, x);
 }
-
diff --git a/src/test/run-fail/divide-by-zero.rs b/src/test/run-fail/divide-by-zero.rs
index d4f3828ea71..9c996807ad8 100644
--- a/src/test/run-fail/divide-by-zero.rs
+++ b/src/test/run-fail/divide-by-zero.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// error-pattern:attempted quotient with a divisor of zero
+// error-pattern:attempted to divide by zero
 fn main() {
     let y = 0;
     let z = 1 / y;
diff --git a/src/test/run-fail/unwind-resource-fail3.rs b/src/test/run-fail/unwind-resource-fail3.rs
index d3ba5737b71..bfbad0b5aea 100644
--- a/src/test/run-fail/unwind-resource-fail3.rs
+++ b/src/test/run-fail/unwind-resource-fail3.rs
@@ -14,7 +14,7 @@ struct faily_box {
     i: @int
 }
 // What happens to the box pointer owned by this class?
- 
+
 fn faily_box(i: @int) -> faily_box { faily_box { i: i } }
 
 #[unsafe_destructor]
diff --git a/src/test/run-pass-fulldeps/qquote.rs b/src/test/run-pass-fulldeps/qquote.rs
index 9bfe29a5e8e..284195f3f04 100644
--- a/src/test/run-pass-fulldeps/qquote.rs
+++ b/src/test/run-pass-fulldeps/qquote.rs
@@ -85,4 +85,3 @@ fn check_pp<T>(cx: fake_ext_ctxt,
         assert!(s == expect);
     }
 }
-
diff --git a/src/test/run-pass-fulldeps/quote-tokens.rs b/src/test/run-pass-fulldeps/quote-tokens.rs
index ccee163eafe..3ec54955229 100644
--- a/src/test/run-pass-fulldeps/quote-tokens.rs
+++ b/src/test/run-pass-fulldeps/quote-tokens.rs
@@ -27,4 +27,3 @@ fn syntax_extension(ext_cx: @ext_ctxt) {
 
 fn main() {
 }
-
diff --git a/src/test/run-pass/anon-trait-static-method.rs b/src/test/run-pass/anon-trait-static-method.rs
index 8e11786786f..91bbbf5c0a0 100644
--- a/src/test/run-pass/anon-trait-static-method.rs
+++ b/src/test/run-pass/anon-trait-static-method.rs
@@ -22,4 +22,3 @@ pub fn main() {
     let x = Foo::new();
     io::println(x.x.to_str());
 }
-
diff --git a/src/test/run-pass/anon_trait_static_method_exe.rs b/src/test/run-pass/anon_trait_static_method_exe.rs
index 5d8b7983688..1baeca00083 100644
--- a/src/test/run-pass/anon_trait_static_method_exe.rs
+++ b/src/test/run-pass/anon_trait_static_method_exe.rs
@@ -18,6 +18,3 @@ pub fn main() {
     let x = Foo::new();
     io::println(x.x.to_str());
 }
-
-
-
diff --git a/src/test/run-pass/auto-encode.rs b/src/test/run-pass/auto-encode.rs
index bfc15acaa76..cfac8e8cd06 100644
--- a/src/test/run-pass/auto-encode.rs
+++ b/src/test/run-pass/auto-encode.rs
@@ -31,11 +31,12 @@ fn test_ebml<A:
     Decodable<EBReader::Decoder>
 >(a1: &A) {
     let bytes = do io::with_bytes_writer |wr| {
-        let ebml_w = &EBWriter::Encoder(wr);
-        a1.encode(ebml_w)
+        let mut ebml_w = EBWriter::Encoder(wr);
+        a1.encode(&mut ebml_w)
     };
     let d = EBReader::Doc(@bytes);
-    let a2: A = Decodable::decode(&EBReader::Decoder(d));
+    let mut decoder = EBReader::Decoder(d);
+    let a2: A = Decodable::decode(&mut decoder);
     assert!(*a1 == a2);
 }
 
diff --git a/src/test/run-pass/auto-ref-newtype.rs b/src/test/run-pass/auto-ref-newtype.rs
index bac6d1aa740..a9fca0ccb15 100644
--- a/src/test/run-pass/auto-ref-newtype.rs
+++ b/src/test/run-pass/auto-ref-newtype.rs
@@ -21,4 +21,3 @@ pub fn main() {
     let m = Foo(3);
     assert!(m.len() == 3);
 }
-
diff --git a/src/test/run-pass/auto-ref.rs b/src/test/run-pass/auto-ref.rs
index f7c0f513a9d..ee250b97219 100644
--- a/src/test/run-pass/auto-ref.rs
+++ b/src/test/run-pass/auto-ref.rs
@@ -26,4 +26,3 @@ pub fn main() {
     let x = Foo { x: 3 };
     x.printme();
 }
-
diff --git a/src/test/run-pass/autoderef-and-borrow-method-receiver.rs b/src/test/run-pass/autoderef-and-borrow-method-receiver.rs
index 883cffa792b..2bc6df47030 100644
--- a/src/test/run-pass/autoderef-and-borrow-method-receiver.rs
+++ b/src/test/run-pass/autoderef-and-borrow-method-receiver.rs
@@ -22,4 +22,3 @@ fn g(x: &mut Foo) {
 
 pub fn main() {
 }
-
diff --git a/src/test/run-pass/bare-static-string.rs b/src/test/run-pass/bare-static-string.rs
index d8015f0b92c..6208a9c3cc3 100644
--- a/src/test/run-pass/bare-static-string.rs
+++ b/src/test/run-pass/bare-static-string.rs
@@ -12,4 +12,3 @@ pub fn main() {
     let x: &'static str = "foo";
     io::println(x);
 }
-
diff --git a/src/test/run-pass/binops.rs b/src/test/run-pass/binops.rs
index e7624c9e3b9..e755a34f058 100644
--- a/src/test/run-pass/binops.rs
+++ b/src/test/run-pass/binops.rs
@@ -104,7 +104,7 @@ fn p(x: int, y: int) -> p {
 fn test_class() {
   let mut q = p(1, 2);
   let mut r = p(1, 2);
-  
+
   unsafe {
   error!("q = %x, r = %x",
          (::core::cast::transmute::<*p, uint>(&q)),
diff --git a/src/test/run-pass/block-arg-in-parentheses.rs b/src/test/run-pass/block-arg-in-parentheses.rs
index ce0b85f414b..ad53bd22754 100644
--- a/src/test/run-pass/block-arg-in-parentheses.rs
+++ b/src/test/run-pass/block-arg-in-parentheses.rs
@@ -33,4 +33,3 @@ pub fn main() {
     assert!(w_paren2(~[0, 1, 2, 3]) == -4);
     assert!(w_ret(~[0, 1, 2, 3]) == -4);
 }
-
diff --git a/src/test/run-pass/borrow-by-val-method-receiver.rs b/src/test/run-pass/borrow-by-val-method-receiver.rs
index fdb51124f0e..fb4316ca1f5 100644
--- a/src/test/run-pass/borrow-by-val-method-receiver.rs
+++ b/src/test/run-pass/borrow-by-val-method-receiver.rs
@@ -20,4 +20,3 @@ pub fn main() {
     let items = ~[ 3, 5, 1, 2, 4 ];
     items.foo();
 }
-
diff --git a/src/test/run-pass/borrowck-wg-simple.rs b/src/test/run-pass/borrowck-wg-simple.rs
index adf2403ec63..f28b0e4c4ec 100644
--- a/src/test/run-pass/borrowck-wg-simple.rs
+++ b/src/test/run-pass/borrowck-wg-simple.rs
@@ -6,4 +6,3 @@ pub fn main() {
     let x = @mut 3;
     f(x);
 }
-
diff --git a/src/test/run-pass/boxed-trait-with-vstore.rs b/src/test/run-pass/boxed-trait-with-vstore.rs
index 1aac86238dc..1313a17f81d 100644
--- a/src/test/run-pass/boxed-trait-with-vstore.rs
+++ b/src/test/run-pass/boxed-trait-with-vstore.rs
@@ -22,4 +22,3 @@ pub fn main() {
     let x = @3 as @Foo;
     x.foo();
 }
-
diff --git a/src/test/run-pass/break.rs b/src/test/run-pass/break.rs
index b3f524c0ad7..a182dcf2ca0 100644
--- a/src/test/run-pass/break.rs
+++ b/src/test/run-pass/break.rs
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-
-
 pub fn main() {
     let mut i = 0;
     while i < 20 { i += 1; if i == 10 { break; } }
@@ -22,8 +20,8 @@ pub fn main() {
     i = 0;
     while i < 10 { i += 1; if i % 2 == 0 { loop; } assert!((i % 2 != 0)); }
     i = 0;
-    loop { 
-        i += 1; if i % 2 == 0 { loop; } assert!((i % 2 != 0)); 
+    loop {
+        i += 1; if i % 2 == 0 { loop; } assert!((i % 2 != 0));
         if i >= 10 { break; }
     }
     for vec::each(~[1, 2, 3, 4, 5, 6]) |x| {
diff --git a/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs b/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs
index 68bc567cf51..76f4e3b68f7 100644
--- a/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs
+++ b/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs
@@ -24,4 +24,3 @@ pub fn main() {
   let nyan : @ToStr = @cat(0u, 2, ~"nyan") as @ToStr;
   print_out(nyan, ~"nyan");
 }
-
diff --git a/src/test/run-pass/class-impl-parameterized-trait.rs b/src/test/run-pass/class-impl-parameterized-trait.rs
index 53ae0021a91..04784b5c515 100644
--- a/src/test/run-pass/class-impl-parameterized-trait.rs
+++ b/src/test/run-pass/class-impl-parameterized-trait.rs
@@ -48,7 +48,7 @@ class cat : map<int, bool> {
   }
 
   fn size() -> uint { self.meows as uint }
-  fn insert(+k: int, +v: bool) -> bool { 
+  fn insert(+k: int, +v: bool) -> bool {
     if v { self.meows += k; } else { self.meows -= k; };
     true
   }
diff --git a/src/test/run-pass/cleanup-copy-mode.rs b/src/test/run-pass/cleanup-copy-mode.rs
index 41f76b1b4f2..b334f32f344 100644
--- a/src/test/run-pass/cleanup-copy-mode.rs
+++ b/src/test/run-pass/cleanup-copy-mode.rs
@@ -16,4 +16,3 @@ pub fn main() {
         adder(@2, failer()); ()
     })));
 }
-
diff --git a/src/test/run-pass/clone-with-exterior.rs b/src/test/run-pass/clone-with-exterior.rs
index 57c4f91142d..ae2983b1594 100644
--- a/src/test/run-pass/clone-with-exterior.rs
+++ b/src/test/run-pass/clone-with-exterior.rs
@@ -18,7 +18,7 @@ struct Pair {
 
 pub fn main() {
     let z = ~Pair { a : 10, b : 12};
-    
+
     let f: ~fn() = || {
         assert!((z.a == 10));
         assert!((z.b == 12));
diff --git a/src/test/run-pass/conditional-compile.rs b/src/test/run-pass/conditional-compile.rs
index 609bfe7a4cb..73fdb219c19 100644
--- a/src/test/run-pass/conditional-compile.rs
+++ b/src/test/run-pass/conditional-compile.rs
@@ -27,7 +27,7 @@ mod rustrt {
         // module was translated
         pub fn bogus();
     }
-    
+
     #[abi = "cdecl"]
     pub extern {}
 }
diff --git a/src/test/run-pass/const-enum-vec-index.rs b/src/test/run-pass/const-enum-vec-index.rs
index 01bab077832..4c81eaae1d8 100644
--- a/src/test/run-pass/const-enum-vec-index.rs
+++ b/src/test/run-pass/const-enum-vec-index.rs
@@ -14,7 +14,7 @@ static C0: E = C[0];
 static C1: E = C[1];
 
 pub fn main() {
-    match C0 { 
+    match C0 {
         V0 => (),
         _ => fail!()
     }
diff --git a/src/test/run-pass/const-enum-vec-ptr.rs b/src/test/run-pass/const-enum-vec-ptr.rs
index 8615356965e..95c4ed836c7 100644
--- a/src/test/run-pass/const-enum-vec-ptr.rs
+++ b/src/test/run-pass/const-enum-vec-ptr.rs
@@ -16,7 +16,7 @@ pub fn main() {
         V1(n) => assert!(n == 0xDEADBEE),
         _ => fail!()
     }
-    match C[2] { 
+    match C[2] {
         V0 => (),
         _ => fail!()
     }
diff --git a/src/test/run-pass/const-enum-vector.rs b/src/test/run-pass/const-enum-vector.rs
index 7ae2c5a2fee..3dc5b918f7f 100644
--- a/src/test/run-pass/const-enum-vector.rs
+++ b/src/test/run-pass/const-enum-vector.rs
@@ -16,7 +16,7 @@ pub fn main() {
         V1(n) => assert!(n == 0xDEADBEE),
         _ => fail!()
     }
-    match C[2] { 
+    match C[2] {
         V0 => (),
         _ => fail!()
     }
diff --git a/src/test/run-pass/const-expr-in-fixed-length-vec.rs b/src/test/run-pass/const-expr-in-fixed-length-vec.rs
index c593fd39aaa..48b41d04633 100644
--- a/src/test/run-pass/const-expr-in-fixed-length-vec.rs
+++ b/src/test/run-pass/const-expr-in-fixed-length-vec.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// Check that constant expressions can be used for declaring the 
+// Check that constant expressions can be used for declaring the
 // type of a fixed length vector.
 
 pub fn main() {
diff --git a/src/test/run-pass/const-expr-in-vec-repeat.rs b/src/test/run-pass/const-expr-in-vec-repeat.rs
index be54c6eb7be..f10cef520ad 100644
--- a/src/test/run-pass/const-expr-in-vec-repeat.rs
+++ b/src/test/run-pass/const-expr-in-vec-repeat.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// Check that constant expressions can be used in vec repeat syntax. 
+// Check that constant expressions can be used in vec repeat syntax.
 
 pub fn main() {
 
diff --git a/src/test/run-pass/const-tuple-struct.rs b/src/test/run-pass/const-tuple-struct.rs
index a68e12b7b10..828c20912a1 100644
--- a/src/test/run-pass/const-tuple-struct.rs
+++ b/src/test/run-pass/const-tuple-struct.rs
@@ -20,4 +20,3 @@ pub fn main() {
         }
     }
 }
-
diff --git a/src/test/run-pass/const-unit-struct.rs b/src/test/run-pass/const-unit-struct.rs
index b4acde098ba..7e6d9f0bee9 100644
--- a/src/test/run-pass/const-unit-struct.rs
+++ b/src/test/run-pass/const-unit-struct.rs
@@ -17,4 +17,3 @@ pub fn main() {
         Foo => {}
     }
 }
-
diff --git a/src/test/run-pass/const-vec-syntax.rs b/src/test/run-pass/const-vec-syntax.rs
index c3e882ac04f..625f6ec30cc 100644
--- a/src/test/run-pass/const-vec-syntax.rs
+++ b/src/test/run-pass/const-vec-syntax.rs
@@ -14,4 +14,3 @@ pub fn main() {
     let v = [ 1, 2, 3 ];
     f(v);
 }
-
diff --git a/src/test/run-pass/consts-in-patterns.rs b/src/test/run-pass/consts-in-patterns.rs
index 408c0e612f4..c0520cf737f 100644
--- a/src/test/run-pass/consts-in-patterns.rs
+++ b/src/test/run-pass/consts-in-patterns.rs
@@ -20,4 +20,3 @@ pub fn main() {
     };
     assert!(y == 2);
 }
-
diff --git a/src/test/run-pass/cycle-collection.rs b/src/test/run-pass/cycle-collection.rs
index 0512b8a1267..0e9be022113 100644
--- a/src/test/run-pass/cycle-collection.rs
+++ b/src/test/run-pass/cycle-collection.rs
@@ -21,4 +21,3 @@ fn f() {
 pub fn main() {
     f();
 }
-
diff --git a/src/test/run-pass/default-method-simple.rs b/src/test/run-pass/default-method-simple.rs
index 62b29d4e4eb..3f44f3f1ef8 100644
--- a/src/test/run-pass/default-method-simple.rs
+++ b/src/test/run-pass/default-method-simple.rs
@@ -32,4 +32,3 @@ pub fn main() {
     let a = A { x: 1 };
     a.f();
 }
-
diff --git a/src/test/run-pass/deriving-clone-enum.rs b/src/test/run-pass/deriving-clone-enum.rs
index 6caceeb2d70..969e1fb5dd6 100644
--- a/src/test/run-pass/deriving-clone-enum.rs
+++ b/src/test/run-pass/deriving-clone-enum.rs
@@ -16,4 +16,3 @@ enum E {
 }
 
 pub fn main() {}
-
diff --git a/src/test/run-pass/deriving-clone-generic-enum.rs b/src/test/run-pass/deriving-clone-generic-enum.rs
index a868db2425c..23841017e93 100644
--- a/src/test/run-pass/deriving-clone-generic-enum.rs
+++ b/src/test/run-pass/deriving-clone-generic-enum.rs
@@ -6,4 +6,3 @@ enum E<T,U> {
 }
 
 fn main() {}
-
diff --git a/src/test/run-pass/deriving-clone-generic-struct.rs b/src/test/run-pass/deriving-clone-generic-struct.rs
index b157cd321cf..0a7a5a3aa75 100644
--- a/src/test/run-pass/deriving-clone-generic-struct.rs
+++ b/src/test/run-pass/deriving-clone-generic-struct.rs
@@ -16,4 +16,3 @@ struct S<T> {
 }
 
 pub fn main() {}
-
diff --git a/src/test/run-pass/deriving-clone-generic-tuple-struct.rs b/src/test/run-pass/deriving-clone-generic-tuple-struct.rs
index aeaa9ed726d..d6a69e8e6ac 100644
--- a/src/test/run-pass/deriving-clone-generic-tuple-struct.rs
+++ b/src/test/run-pass/deriving-clone-generic-tuple-struct.rs
@@ -2,4 +2,3 @@
 struct S<T>(T, ());
 
 fn main() {}
-
diff --git a/src/test/run-pass/deriving-clone-tuple-struct.rs b/src/test/run-pass/deriving-clone-tuple-struct.rs
index c534883f600..1e5c8c80f8c 100644
--- a/src/test/run-pass/deriving-clone-tuple-struct.rs
+++ b/src/test/run-pass/deriving-clone-tuple-struct.rs
@@ -12,4 +12,3 @@
 struct S((), ());
 
 pub fn main() {}
-
diff --git a/src/test/run-pass/deriving-via-extension-c-enum.rs b/src/test/run-pass/deriving-via-extension-c-enum.rs
index 67893ae9c1e..81c4ce013f2 100644
--- a/src/test/run-pass/deriving-via-extension-c-enum.rs
+++ b/src/test/run-pass/deriving-via-extension-c-enum.rs
@@ -23,4 +23,3 @@ pub fn main() {
     assert!(a.eq(&b));
     assert!(!a.ne(&b));
 }
-
diff --git a/src/test/run-pass/deriving-via-extension-enum.rs b/src/test/run-pass/deriving-via-extension-enum.rs
index 7481bae508b..fac0d402a38 100644
--- a/src/test/run-pass/deriving-via-extension-enum.rs
+++ b/src/test/run-pass/deriving-via-extension-enum.rs
@@ -22,4 +22,3 @@ pub fn main() {
     assert!(a.eq(&b));
     assert!(!a.ne(&b));
 }
-
diff --git a/src/test/run-pass/deriving-via-extension-iter-bytes-enum.rs b/src/test/run-pass/deriving-via-extension-iter-bytes-enum.rs
index 5ceb8c48750..b08117b71fa 100644
--- a/src/test/run-pass/deriving-via-extension-iter-bytes-enum.rs
+++ b/src/test/run-pass/deriving-via-extension-iter-bytes-enum.rs
@@ -25,4 +25,3 @@ enum A {
 }
 
 pub fn main(){}
-
diff --git a/src/test/run-pass/deriving-via-extension-iter-bytes-struct.rs b/src/test/run-pass/deriving-via-extension-iter-bytes-struct.rs
index 9f18cb6ac58..8369d12ecdd 100644
--- a/src/test/run-pass/deriving-via-extension-iter-bytes-struct.rs
+++ b/src/test/run-pass/deriving-via-extension-iter-bytes-struct.rs
@@ -18,5 +18,3 @@ struct Foo {
 }
 
 pub fn main() {}
-
-
diff --git a/src/test/run-pass/deriving-via-extension-struct-like-enum-variant.rs b/src/test/run-pass/deriving-via-extension-struct-like-enum-variant.rs
index 712767efacf..4ef8fb6b5d9 100644
--- a/src/test/run-pass/deriving-via-extension-struct-like-enum-variant.rs
+++ b/src/test/run-pass/deriving-via-extension-struct-like-enum-variant.rs
@@ -9,4 +9,3 @@ pub fn main() {
     assert!(x == x);
     assert!(!(x != x));
 }
-
diff --git a/src/test/run-pass/deriving-via-extension-struct.rs b/src/test/run-pass/deriving-via-extension-struct.rs
index 1e004d1a8c0..c0e7ee36b16 100644
--- a/src/test/run-pass/deriving-via-extension-struct.rs
+++ b/src/test/run-pass/deriving-via-extension-struct.rs
@@ -23,4 +23,3 @@ pub fn main() {
     assert!(a.eq(&b));
     assert!(!a.ne(&b));
 }
-
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 f310643f943..85a89c62989 100644
--- a/src/test/run-pass/deriving-via-extension-type-params.rs
+++ b/src/test/run-pass/deriving-via-extension-type-params.rs
@@ -26,4 +26,3 @@ pub fn main() {
     assert!(a.eq(&b));
     assert!(!a.ne(&b));
 }
-
diff --git a/src/test/run-pass/drop-trait-generic.rs b/src/test/run-pass/drop-trait-generic.rs
index 21b85084117..65c3faac2b3 100644
--- a/src/test/run-pass/drop-trait-generic.rs
+++ b/src/test/run-pass/drop-trait-generic.rs
@@ -22,4 +22,3 @@ impl<T> ::core::ops::Drop for S<T> {
 pub fn main() {
     let x = S { x: 1 };
 }
-
diff --git a/src/test/run-pass/drop-trait.rs b/src/test/run-pass/drop-trait.rs
index 3eddda376a8..b516c6f6de4 100644
--- a/src/test/run-pass/drop-trait.rs
+++ b/src/test/run-pass/drop-trait.rs
@@ -21,4 +21,3 @@ impl Drop for Foo {
 pub fn main() {
     let x: Foo = Foo { x: 3 };
 }
-
diff --git a/src/test/run-pass/enum-discrim-range-overflow.rs b/src/test/run-pass/enum-discrim-range-overflow.rs
index a6806fba142..37e457d547b 100644
--- a/src/test/run-pass/enum-discrim-range-overflow.rs
+++ b/src/test/run-pass/enum-discrim-range-overflow.rs
@@ -9,23 +9,23 @@
 // except according to those terms.
 
 pub enum E64 {
-	H64 = 0x7FFF_FFFF_FFFF_FFFF,
-	L64 = 0x8000_0000_0000_0000
+    H64 = 0x7FFF_FFFF_FFFF_FFFF,
+    L64 = 0x8000_0000_0000_0000
 }
 pub enum E32 {
-	H32 = 0x7FFF_FFFF,
-	L32 = 0x8000_0000
+    H32 = 0x7FFF_FFFF,
+    L32 = 0x8000_0000
 }
 
 pub fn f(e64: E64, e32: E32) -> (bool,bool) {
-	(match e64 {
-		H64 => true,
-		L64 => false
-	},
-	 match e32 {
-		H32 => true,
-		L32 => false
-	})
+    (match e64 {
+        H64 => true,
+        L64 => false
+    },
+     match e32 {
+        H32 => true,
+        L32 => false
+    })
 }
 
 pub fn main() { }
diff --git a/src/test/run-pass/enum-disr-val-pretty.rs b/src/test/run-pass/enum-disr-val-pretty.rs
index 39a807789ec..2c61351cf44 100644
--- a/src/test/run-pass/enum-disr-val-pretty.rs
+++ b/src/test/run-pass/enum-disr-val-pretty.rs
@@ -23,4 +23,3 @@ fn test_color(color: color, val: int, name: ~str) {
     assert!(color as int == val);
     assert!(color as float == val as float);
 }
-
diff --git a/src/test/run-pass/enum-export-inheritance.rs b/src/test/run-pass/enum-export-inheritance.rs
index c3beebdb8ae..49823155043 100644
--- a/src/test/run-pass/enum-export-inheritance.rs
+++ b/src/test/run-pass/enum-export-inheritance.rs
@@ -19,4 +19,3 @@ mod a {
 pub fn main() {
     let x = a::Bar;
 }
-
diff --git a/src/libcore/rt/io/net/mod.rs b/src/test/run-pass/enum-nullable-simplifycfg-misopt.rs
index 130ff6b38fa..4764dbb9417 100644
--- a/src/libcore/rt/io/net/mod.rs
+++ b/src/test/run-pass/enum-nullable-simplifycfg-misopt.rs
@@ -8,24 +8,17 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use prelude::*;
+/*!
+ * This is a regression test for a bug in LLVM, fixed in upstream r179587,
+ * where the switch instructions generated for destructuring enums
+ * represented with nullable pointers could be misoptimized in some cases.
+ */
 
-pub mod tcp;
-pub mod udp;
-pub mod ip;
-#[cfg(unix)]
-pub mod unix;
-pub mod http;
-
-/// A listener is a value that listens for connections
-pub trait Listener<S> {
-    /// Wait for and accept an incoming connection
-    ///
-    /// Returns `None` on timeout.
-    ///
-    /// # Failure
-    ///
-    /// Raises `io_error` condition. If the condition is handled,
-    /// then `accept` returns `None`.
-    fn accept(&mut self) -> Option<S>;
+enum List<X> { Nil, Cons(X, @List<X>) }
+pub fn main() {
+    match Cons(10, @Nil) {
+        Cons(10, _) => {}
+        Nil => {}
+        _ => fail!()
+    }
 }
diff --git a/src/test/run-pass/explicit-self-generic.rs b/src/test/run-pass/explicit-self-generic.rs
index 1a2a8cab303..ac19592accf 100644
--- a/src/test/run-pass/explicit-self-generic.rs
+++ b/src/test/run-pass/explicit-self-generic.rs
@@ -40,4 +40,3 @@ pub fn main() {
     let mut m = ~linear_map::<(),()>();
     assert!(m.len() == 0);
 }
-
diff --git a/src/test/run-pass/explicit-self-objects-box.rs b/src/test/run-pass/explicit-self-objects-box.rs
index 105aad03083..12a1780e029 100644
--- a/src/test/run-pass/explicit-self-objects-box.rs
+++ b/src/test/run-pass/explicit-self-objects-box.rs
@@ -30,5 +30,3 @@ pub fn main() {
     y.f();
     y.f();
 }
-
-
diff --git a/src/test/run-pass/explicit-self-objects-simple.rs b/src/test/run-pass/explicit-self-objects-simple.rs
index de2926b0e7e..814365a8354 100644
--- a/src/test/run-pass/explicit-self-objects-simple.rs
+++ b/src/test/run-pass/explicit-self-objects-simple.rs
@@ -27,5 +27,3 @@ pub fn main() {
     let y = x as @Foo;
     y.f();
 }
-
-
diff --git a/src/test/run-pass/explicit-self-objects-uniq.rs b/src/test/run-pass/explicit-self-objects-uniq.rs
index e99a6bbedc0..dadf53fb9bc 100644
--- a/src/test/run-pass/explicit-self-objects-uniq.rs
+++ b/src/test/run-pass/explicit-self-objects-uniq.rs
@@ -27,5 +27,3 @@ pub fn main() {
     let y = x as ~Foo;
     y.f();
 }
-
-
diff --git a/src/test/run-pass/explicit_self_xcrate_exe.rs b/src/test/run-pass/explicit_self_xcrate_exe.rs
index e217e6ebd41..6f6520e8040 100644
--- a/src/test/run-pass/explicit_self_xcrate_exe.rs
+++ b/src/test/run-pass/explicit_self_xcrate_exe.rs
@@ -18,4 +18,3 @@ pub fn main() {
     let x = Bar { x: ~"hello" };
     x.f();
 }
-
diff --git a/src/test/run-pass/expr-repeat-vstore.rs b/src/test/run-pass/expr-repeat-vstore.rs
index 972b2763b1b..e48abc57534 100644
--- a/src/test/run-pass/expr-repeat-vstore.rs
+++ b/src/test/run-pass/expr-repeat-vstore.rs
@@ -20,4 +20,3 @@ fn main() {
     println((copy v[3]).to_str());
     println((copy v[4]).to_str());
 }
-
diff --git a/src/test/run-pass/extern-mod-abi.rs b/src/test/run-pass/extern-mod-abi.rs
index 7eada51b7c7..84fd1b40bf7 100644
--- a/src/test/run-pass/extern-mod-abi.rs
+++ b/src/test/run-pass/extern-mod-abi.rs
@@ -13,4 +13,3 @@ extern "C" {
 }
 
 pub fn main() {}
-
diff --git a/src/test/run-pass/extern-mod-ordering-exe.rs b/src/test/run-pass/extern-mod-ordering-exe.rs
index b60302277b3..5836245ff78 100644
--- a/src/test/run-pass/extern-mod-ordering-exe.rs
+++ b/src/test/run-pass/extern-mod-ordering-exe.rs
@@ -8,4 +8,3 @@ use extern_mod_ordering_lib::extern_mod_ordering_lib;
 fn main() {
     extern_mod_ordering_lib::f();
 }
-
diff --git a/src/test/run-pass/extern-mod-syntax.rs b/src/test/run-pass/extern-mod-syntax.rs
index b6b2e004263..c98b5ebc238 100644
--- a/src/test/run-pass/extern-mod-syntax.rs
+++ b/src/test/run-pass/extern-mod-syntax.rs
@@ -16,4 +16,3 @@ use std::json::Object;
 pub fn main() {
     io::println("Hello world!");
 }
-
diff --git a/src/test/run-pass/extern-pass-TwoU16s.rs b/src/test/run-pass/extern-pass-TwoU16s.rs
index f0343c4d2a2..ec65cbb5670 100644
--- a/src/test/run-pass/extern-pass-TwoU16s.rs
+++ b/src/test/run-pass/extern-pass-TwoU16s.rs
@@ -29,4 +29,3 @@ pub fn main() {
         assert!(x == y);
     }
 }
-
diff --git a/src/test/run-pass/extern-pass-TwoU32s.rs b/src/test/run-pass/extern-pass-TwoU32s.rs
index 16d14a96cfe..6ac5967c54f 100644
--- a/src/test/run-pass/extern-pass-TwoU32s.rs
+++ b/src/test/run-pass/extern-pass-TwoU32s.rs
@@ -27,4 +27,3 @@ pub fn main() {
         assert!(x == y);
     }
 }
-
diff --git a/src/test/run-pass/extern-pass-TwoU64s-ref.rs b/src/test/run-pass/extern-pass-TwoU64s-ref.rs
index 56d3f8ebbff..2b18dba90f7 100644
--- a/src/test/run-pass/extern-pass-TwoU64s-ref.rs
+++ b/src/test/run-pass/extern-pass-TwoU64s-ref.rs
@@ -26,4 +26,3 @@ pub fn main() {
         assert!(x == y);
     }
 }
-
diff --git a/src/test/run-pass/extern-pass-TwoU64s.rs b/src/test/run-pass/extern-pass-TwoU64s.rs
index 24dd3db8aca..3a1f4a51238 100644
--- a/src/test/run-pass/extern-pass-TwoU64s.rs
+++ b/src/test/run-pass/extern-pass-TwoU64s.rs
@@ -31,4 +31,3 @@ pub fn main() {
         assert!(x == y);
     }
 }
-
diff --git a/src/test/run-pass/extern-pass-TwoU8s.rs b/src/test/run-pass/extern-pass-TwoU8s.rs
index 213e9a68a7f..7d08b436908 100644
--- a/src/test/run-pass/extern-pass-TwoU8s.rs
+++ b/src/test/run-pass/extern-pass-TwoU8s.rs
@@ -29,4 +29,3 @@ pub fn main() {
         assert!(x == y);
     }
 }
-
diff --git a/src/test/run-pass/extern-pass-char.rs b/src/test/run-pass/extern-pass-char.rs
index f4fa6bde392..645396e5a98 100644
--- a/src/test/run-pass/extern-pass-char.rs
+++ b/src/test/run-pass/extern-pass-char.rs
@@ -19,4 +19,3 @@ pub fn main() {
         assert!(22_u8 == rust_dbg_extern_identity_u8(22_u8));
     }
 }
-
diff --git a/src/test/run-pass/extern-pass-double.rs b/src/test/run-pass/extern-pass-double.rs
index 4e16acb4ad5..3a6dd26a9dc 100644
--- a/src/test/run-pass/extern-pass-double.rs
+++ b/src/test/run-pass/extern-pass-double.rs
@@ -17,4 +17,3 @@ pub fn main() {
         assert!(22.0_f64 == rust_dbg_extern_identity_double(22.0_f64));
     }
 }
-
diff --git a/src/test/run-pass/extern-pass-u32.rs b/src/test/run-pass/extern-pass-u32.rs
index 14d05f82177..19c4d6e1539 100644
--- a/src/test/run-pass/extern-pass-u32.rs
+++ b/src/test/run-pass/extern-pass-u32.rs
@@ -19,4 +19,3 @@ pub fn main() {
         assert!(22_u32 == rust_dbg_extern_identity_u32(22_u32));
     }
 }
-
diff --git a/src/test/run-pass/extern-pass-u64.rs b/src/test/run-pass/extern-pass-u64.rs
index 2b5a03a4d71..cce66999922 100644
--- a/src/test/run-pass/extern-pass-u64.rs
+++ b/src/test/run-pass/extern-pass-u64.rs
@@ -19,4 +19,3 @@ pub fn main() {
         assert!(22_u64 == rust_dbg_extern_identity_u64(22_u64));
     }
 }
-
diff --git a/src/test/run-pass/extern-pub.rs b/src/test/run-pass/extern-pub.rs
index 9bfeec8c7d6..f9b0ccbb548 100644
--- a/src/test/run-pass/extern-pub.rs
+++ b/src/test/run-pass/extern-pub.rs
@@ -6,5 +6,3 @@ extern {
 
 pub fn main() {
 }
-
-
diff --git a/src/test/run-pass/fat-arrow-alt.rs b/src/test/run-pass/fat-arrow-alt.rs
index 4b8b552bfae..f6b49960fad 100644
--- a/src/test/run-pass/fat-arrow-alt.rs
+++ b/src/test/run-pass/fat-arrow-alt.rs
@@ -23,4 +23,3 @@ pub fn main() {
         blue => { 3 }
     });
 }
-
diff --git a/src/test/run-pass/fixed_length_copy.rs b/src/test/run-pass/fixed_length_copy.rs
index 5daa525d9b1..7ee3f5173b0 100644
--- a/src/test/run-pass/fixed_length_copy.rs
+++ b/src/test/run-pass/fixed_length_copy.rs
@@ -10,7 +10,7 @@
 
 
 // error on implicit copies to check fixed length vectors
-// are implicitly copyable 
+// are implicitly copyable
 #[deny(implicit_copies)]
 pub fn main() {
     let arr = [1,2,3];
diff --git a/src/test/run-pass/float-literal-inference.rs b/src/test/run-pass/float-literal-inference.rs
index 2b59d7bfcee..a5246eef0b0 100644
--- a/src/test/run-pass/float-literal-inference.rs
+++ b/src/test/run-pass/float-literal-inference.rs
@@ -20,4 +20,3 @@ pub fn main() {
     let z = S { z: 1.0 };
     io::println(z.z.to_str());
 }
-
diff --git a/src/test/run-pass/fn-pattern-expected-type-2.rs b/src/test/run-pass/fn-pattern-expected-type-2.rs
index f9bf9b5915e..501bd81d558 100644
--- a/src/test/run-pass/fn-pattern-expected-type-2.rs
+++ b/src/test/run-pass/fn-pattern-expected-type-2.rs
@@ -15,4 +15,3 @@ pub fn main() {
         io::println(x.to_str());
     }
 }
-
diff --git a/src/test/run-pass/fn-pattern-expected-type.rs b/src/test/run-pass/fn-pattern-expected-type.rs
index dc3f33a1991..f3949a0f43b 100644
--- a/src/test/run-pass/fn-pattern-expected-type.rs
+++ b/src/test/run-pass/fn-pattern-expected-type.rs
@@ -15,4 +15,3 @@ pub fn main() {
     };
     f((1, 2));
 }
-
diff --git a/src/test/run-pass/foreign-mod-unused-const.rs b/src/test/run-pass/foreign-mod-unused-const.rs
index 430da7a3f60..4909e9d7e56 100644
--- a/src/test/run-pass/foreign-mod-unused-const.rs
+++ b/src/test/run-pass/foreign-mod-unused-const.rs
@@ -17,4 +17,3 @@ mod foo {
 
 pub fn main() {
 }
-
diff --git a/src/test/run-pass/functional-struct-update.rs b/src/test/run-pass/functional-struct-update.rs
index f1db6db417a..297b5e78a92 100644
--- a/src/test/run-pass/functional-struct-update.rs
+++ b/src/test/run-pass/functional-struct-update.rs
@@ -18,4 +18,3 @@ pub fn main() {
     let c = Foo { x: 4, .. a};
     io::println(fmt!("%?", c));
 }
-
diff --git a/src/test/run-pass/generic-ivec-leak.rs b/src/test/run-pass/generic-ivec-leak.rs
index 8d9b0fa6ddb..ac6e3e1a69a 100644
--- a/src/test/run-pass/generic-ivec-leak.rs
+++ b/src/test/run-pass/generic-ivec-leak.rs
@@ -11,4 +11,3 @@
 enum wrapper<T> { wrapped(T), }
 
 pub fn main() { let w = wrapped(~[1, 2, 3, 4, 5]); }
-
diff --git a/src/test/run-pass/generic-ivec.rs b/src/test/run-pass/generic-ivec.rs
index 031821d9909..2a288c8abbf 100644
--- a/src/test/run-pass/generic-ivec.rs
+++ b/src/test/run-pass/generic-ivec.rs
@@ -10,4 +10,3 @@
 
 fn f<T>(v: @T) { }
 pub fn main() { f(@~[1, 2, 3, 4, 5]); }
-
diff --git a/src/test/run-pass/generic-newtype-struct.rs b/src/test/run-pass/generic-newtype-struct.rs
index 7c7d73eda10..cf4279d67b8 100644
--- a/src/test/run-pass/generic-newtype-struct.rs
+++ b/src/test/run-pass/generic-newtype-struct.rs
@@ -4,4 +4,3 @@ pub fn main() {
     let s = S(2i);
     io::println(s.to_str());
 }
-
diff --git a/src/test/run-pass/generic-object.rs b/src/test/run-pass/generic-object.rs
index ebfc362c72c..54ae2c58e42 100644
--- a/src/test/run-pass/generic-object.rs
+++ b/src/test/run-pass/generic-object.rs
@@ -27,4 +27,3 @@ pub fn main() {
     let y = x as @Foo<int>;
     assert!(y.get() == 1);
 }
-
diff --git a/src/test/run-pass/global-scope.rs b/src/test/run-pass/global-scope.rs
index 3dd912dea9a..9b292a325c0 100644
--- a/src/test/run-pass/global-scope.rs
+++ b/src/test/run-pass/global-scope.rs
@@ -18,4 +18,3 @@ pub mod foo {
 }
 
 pub fn main() { return foo::g(); }
-
diff --git a/src/test/run-pass/impl-privacy-xc-1.rs b/src/test/run-pass/impl-privacy-xc-1.rs
index df001c7ab21..19d3caf818d 100644
--- a/src/test/run-pass/impl-privacy-xc-1.rs
+++ b/src/test/run-pass/impl-privacy-xc-1.rs
@@ -7,4 +7,3 @@ pub fn main() {
     let fish = impl_privacy_xc_1::Fish { x: 1 };
     fish.swim();
 }
-
diff --git a/src/test/run-pass/impl-privacy-xc-2.rs b/src/test/run-pass/impl-privacy-xc-2.rs
index 69bd31ab766..74d9a34e161 100644
--- a/src/test/run-pass/impl-privacy-xc-2.rs
+++ b/src/test/run-pass/impl-privacy-xc-2.rs
@@ -8,4 +8,3 @@ pub fn main() {
     let fish2 = impl_privacy_xc_2::Fish { x: 2 };
     io::println(if fish1.eq(&fish2) { "yes" } else { "no " });
 }
-
diff --git a/src/test/run-pass/infinite-loops.rs b/src/test/run-pass/infinite-loops.rs
index 611a4b9ccab..b2ed6d95c20 100644
--- a/src/test/run-pass/infinite-loops.rs
+++ b/src/test/run-pass/infinite-loops.rs
@@ -21,9 +21,9 @@ fn loopy(n: int) {
     loop { }
 }
 
-pub fn main() { 
+pub fn main() {
     // Commenting this out, as this will hang forever otherwise.
     // Even after seeing the comment above, I'm not sure what the
     // intention of this test is.
-    // do spawn { loopy(5) }; 
+    // do spawn { loopy(5) };
 }
diff --git a/src/test/run-pass/instantiable.rs b/src/test/run-pass/instantiable.rs
index c140a66ffe4..2173bae85e1 100644
--- a/src/test/run-pass/instantiable.rs
+++ b/src/test/run-pass/instantiable.rs
@@ -18,4 +18,3 @@ struct X { x: uint, nxt: *foo }
 pub fn main() {
     let x = foo(X {x: 0, nxt: ptr::null()});
 }
-
diff --git a/src/test/run-pass/int-conversion-coherence.rs b/src/test/run-pass/int-conversion-coherence.rs
index 235fab107e7..ef2a84da219 100644
--- a/src/test/run-pass/int-conversion-coherence.rs
+++ b/src/test/run-pass/int-conversion-coherence.rs
@@ -23,4 +23,3 @@ impl foo of plus for int { fn plus() -> int { self + 10 } }
 pub fn main() {
     assert!(10.plus() == 20);
 }
-
diff --git a/src/test/run-pass/intrinsics-integer.rs b/src/test/run-pass/intrinsics-integer.rs
index b96ea8cbb7b..1a0d97a5c5b 100644
--- a/src/test/run-pass/intrinsics-integer.rs
+++ b/src/test/run-pass/intrinsics-integer.rs
@@ -89,7 +89,7 @@ pub fn main() {
         assert!((cttz16(-1i16) == 0i16));
         assert!((cttz32(-1i32) == 0i32));
         assert!((cttz64(-1i64) == 0i64));
-        
+
         assert!((cttz8(0i8) == 8i8));
         assert!((cttz16(0i16) == 16i16));
         assert!((cttz32(0i32) == 32i32));
diff --git a/src/test/run-pass/intrinsics-math.rs b/src/test/run-pass/intrinsics-math.rs
index 60e32a56ee5..6f9179bc89d 100644
--- a/src/test/run-pass/intrinsics-math.rs
+++ b/src/test/run-pass/intrinsics-math.rs
@@ -83,7 +83,7 @@ pub fn main() {
 
         assert!((log2f32(8f32).fuzzy_eq(&3f32)));
         assert!((log2f64(f64::consts::e).fuzzy_eq(&f64::consts::log2_e)));
-      
+
         assert!((fmaf32(1.0f32, 2.0f32, 5.0f32).fuzzy_eq(&7.0f32)));
         assert!((fmaf64(0.0f64, -2.0f64, f64::consts::e).fuzzy_eq(&f64::consts::e)));
 
@@ -97,7 +97,7 @@ pub fn main() {
         // undefined reference to llvm.ceil.f32/64
         //assert!((ceilf32(-2.3f32) == -2.0f32));
         //assert!((ceilf64(3.8f64) == 4.0f64));
-      
+
         // Causes linker error
         // undefined reference to llvm.trunc.f32/64
         //assert!((truncf32(0.1f32) == 0.0f32));
diff --git a/src/test/run-pass/issue-1516.rs b/src/test/run-pass/issue-1516.rs
index 33be716cc5f..fe3feeb3dbf 100644
--- a/src/test/run-pass/issue-1516.rs
+++ b/src/test/run-pass/issue-1516.rs
@@ -10,4 +10,3 @@
 
 // xfail-test
 pub fn main() {  let early_error: @fn(str) -> !  = {|msg| fail!() }; }
-
diff --git a/src/test/run-pass/issue-1989.rs b/src/test/run-pass/issue-1989.rs
deleted file mode 100644
index e3327283a81..00000000000
--- a/src/test/run-pass/issue-1989.rs
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// exec-env:RUST_CC_ZEAL=1
-
-enum maybe_pointy {
-    none,
-    p(@mut Pointy)
-}
-
-struct Pointy {
-    a : maybe_pointy,
-    f : @fn()->(),
-}
-
-fn empty_pointy() -> @mut Pointy {
-    return @mut Pointy{
-        a : none,
-        f : || {},
-    }
-}
-
-pub fn main() {
-    let v = ~[empty_pointy(), empty_pointy()];
-    v[0].a = p(v[0]);
-}
diff --git a/src/test/run-pass/issue-2185.rs b/src/test/run-pass/issue-2185.rs
index ac680d3d12e..5b320ddc06b 100644
--- a/src/test/run-pass/issue-2185.rs
+++ b/src/test/run-pass/issue-2185.rs
@@ -8,22 +8,46 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// xfail-test FIXME #2263
+// does the second one subsume the first?
+// xfail-test
 // xfail-fast
+
+// notes on this test case:
+// On Thu, Apr 18, 2013 at 6:30 PM, John Clements <clements@brinckerhoff.org> wrote:
+// the "issue-2185.rs" test was xfailed with a ref to #2263. Issue #2263 is now fixed, so I tried it again, and after adding some &self parameters, I got this error:
+//
+// Running /usr/local/bin/rustc:
+// issue-2185.rs:24:0: 26:1 error: conflicting implementations for a trait
+// issue-2185.rs:24 impl iterable<uint> for @fn(&fn(uint)) {
+// issue-2185.rs:25     fn iter(&self, blk: &fn(v: uint)) { self( |i| blk(i) ) }
+// issue-2185.rs:26 }
+// issue-2185.rs:20:0: 22:1 note: note conflicting implementation here
+// issue-2185.rs:20 impl<A> iterable<A> for @fn(&fn(A)) {
+// issue-2185.rs:21     fn iter(&self, blk: &fn(A)) { self(blk); }
+// issue-2185.rs:22 }
+//
+// … so it looks like it's just not possible to implement both the generic iterable<uint> and iterable<A> for the type iterable<uint>. Is it okay if I just remove this test?
+//
+// but Niko responded:
+// think it's fine to remove this test, just because it's old and cruft and not hard to reproduce. *However* it should eventually be possible to implement the same interface for the same type multiple times with different type parameters, it's just that our current trait implementation has accidental limitations.
+
+// so I'm leaving it in.
+// actually, it looks like this is related to bug #3429. I'll rename this bug.
+
 // This test had to do with an outdated version of the iterable trait.
 // However, the condition it was testing seemed complex enough to
 // warrant still having a test, so I inlined the old definitions.
 
 trait iterable<A> {
-    fn iter(blk: &fn(A));
+    fn iter(&self, blk: &fn(A));
 }
 
 impl<A> iterable<A> for @fn(&fn(A)) {
-    fn iter(blk: &fn(A)) { self(blk); }
+    fn iter(&self, blk: &fn(A)) { self(blk); }
 }
 
 impl iterable<uint> for @fn(&fn(uint)) {
-    fn iter(blk: &fn(&&v: uint)) { self( |i| blk(i) ) }
+    fn iter(&self, blk: &fn(v: uint)) { self( |i| blk(i) ) }
 }
 
 fn filter<A,IA:iterable<A>>(self: IA, prd: @fn(A) -> bool, blk: &fn(A)) {
diff --git a/src/test/run-pass/issue-2196.rs b/src/test/run-pass/issue-2196.rs
deleted file mode 100644
index 3fce821561a..00000000000
--- a/src/test/run-pass/issue-2196.rs
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// xfail-test
-// aux-build:issue-2196-a.rs
-// aux-build:issue-2196-b.rs
-// aux-build:issue-2196-c.rc
-
-use c(name = "issue2196c");
-use c::t;
-
-pub fn main() { }
diff --git a/src/test/run-pass/issue-2216.rs b/src/test/run-pass/issue-2216.rs
index 98965cb6d91..c3a2a4c0b7e 100644
--- a/src/test/run-pass/issue-2216.rs
+++ b/src/test/run-pass/issue-2216.rs
@@ -10,7 +10,7 @@
 
 pub fn main() {
     let mut x = 0;
-    
+
     'foo: loop {
         'bar: loop {
             'quux: loop {
diff --git a/src/test/run-pass/issue-2526-a.rs b/src/test/run-pass/issue-2526-a.rs
index c91b5dd303c..39ce74947e9 100644
--- a/src/test/run-pass/issue-2526-a.rs
+++ b/src/test/run-pass/issue-2526-a.rs
@@ -15,4 +15,3 @@ extern mod issue_2526;
 use issue_2526::*;
 
 pub fn main() {}
-
diff --git a/src/test/run-pass/issue-2734.rs b/src/test/run-pass/issue-2734.rs
index 7125e89287c..319146d0a81 100644
--- a/src/test/run-pass/issue-2734.rs
+++ b/src/test/run-pass/issue-2734.rs
@@ -8,8 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-trait hax { } 
-impl<A> hax for A { } 
+trait hax { }
+impl<A> hax for A { }
 
 fn perform_hax<T:'static>(x: @T) -> @hax {
     @x as @hax
diff --git a/src/test/run-pass/issue-2869.rs b/src/test/run-pass/issue-2869.rs
deleted file mode 100644
index 619f4b4d7db..00000000000
--- a/src/test/run-pass/issue-2869.rs
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// xfail-test
-enum pat { pat_ident(Option<uint>) }
-
-fn f(pat: pat) -> bool { true }
-
-fn num_bindings(pat: pat) -> uint {
-    match pat {
-      pat_ident(_) if f(pat) { 0 }
-      pat_ident(None) { 1 }
-      pat_ident(Some(sub)) { sub }
-    }
-}
-
-pub fn main() {}
diff --git a/src/test/run-pass/issue-2904.rs b/src/test/run-pass/issue-2904.rs
index ef7fd691577..77cc6b3e1b5 100644
--- a/src/test/run-pass/issue-2904.rs
+++ b/src/test/run-pass/issue-2904.rs
@@ -37,7 +37,7 @@ impl to_str::ToStr for square {
           closed_lift => { ~"L" }
           open_lift => { ~"O" }
           earth => { ~"." }
-          empty => { ~" " } 
+          empty => { ~" " }
         }
     }
 }
diff --git a/src/test/run-pass/issue-3176.rs b/src/test/run-pass/issue-3176.rs
index 03b1c127c55..55d62a5bf8e 100644
--- a/src/test/run-pass/issue-3176.rs
+++ b/src/test/run-pass/issue-3176.rs
@@ -20,7 +20,7 @@ pub fn main() {
             p2.recv();
             error!("sibling fails");
             fail!();
-        }   
+        }
         let (p3,c3) = comm::stream();
         c.send(c3);
         c2.send(());
@@ -28,7 +28,7 @@ pub fn main() {
         let (p, c) = comm::stream();
         (p, p3).select();
         c.send(());
-    };  
+    };
     error!("parent tries");
     assert!(!p.recv().try_send(()));
     error!("all done!");
diff --git a/src/test/run-pass/issue-3250.rs b/src/test/run-pass/issue-3250.rs
index a563544b5c7..0a93b89a94d 100644
--- a/src/test/run-pass/issue-3250.rs
+++ b/src/test/run-pass/issue-3250.rs
@@ -2,6 +2,4 @@
 
 type t = (uint, uint);
 
- 
-
 pub fn main() { }
diff --git a/src/test/run-pass/issue-1895.rs b/src/test/run-pass/issue-3429.rs
index 67877795cc0..7bfb928e86d 100644
--- a/src/test/run-pass/issue-1895.rs
+++ b/src/test/run-pass/issue-3429.rs
@@ -13,4 +13,3 @@ pub fn main() {
   let y: @fn() -> int = || x;
   let z = y();
 }
-
diff --git a/src/test/run-pass/issue-3461.rs b/src/test/run-pass/issue-3461.rs
index 4c4144f28e8..dae35d7237b 100644
--- a/src/test/run-pass/issue-3461.rs
+++ b/src/test/run-pass/issue-3461.rs
@@ -12,6 +12,6 @@
 pub fn main() {
 
     fn foo() { }
-    
+
     let bar: ~fn() = ~foo;
 }
diff --git a/src/test/run-pass/issue-3480.rs b/src/test/run-pass/issue-3480.rs
deleted file mode 100644
index aaff822398d..00000000000
--- a/src/test/run-pass/issue-3480.rs
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// xfail-test
-type IMap<K:Copy,V:Copy> = ~[(K, V)];
-
-trait ImmutableMap<K:Copy,V:Copy>
-{
-    fn contains_key(key: K) -> bool;
-}
-
-impl<K:Copy,V:Copy> IMap<K, V> : ImmutableMap<K, V>
-{
-    fn contains_key(key: K) -> bool {
-        vec::find(self, |e| {e.first() == key}).is_some()
-    }
-}
-
-pub fn main() {}
diff --git a/src/test/run-pass/issue-3556.rs b/src/test/run-pass/issue-3556.rs
index 703dcd54f0a..ff2fa80102b 100644
--- a/src/test/run-pass/issue-3556.rs
+++ b/src/test/run-pass/issue-3556.rs
@@ -10,7 +10,7 @@
 
 extern mod std;
 use core::io::WriterUtil;
-    
+
 enum Token {
         Text(@~str),
         ETag(@~[~str], @~str),
@@ -19,7 +19,7 @@ enum Token {
         IncompleteSection(@~[~str], bool, @~str, bool),
         Partial(@~str, @~str, @~str),
 }
-    
+
 fn check_strs(actual: &str, expected: &str) -> bool
 {
         if actual != expected
@@ -29,12 +29,12 @@ fn check_strs(actual: &str, expected: &str) -> bool
         }
         return true;
 }
-    
+
 pub fn main()
 {
  //       assert!(check_strs(fmt!("%?", Text(@~"foo")), "Text(@~\"foo\")"));
  //       assert!(check_strs(fmt!("%?", ETag(@~[~"foo"], @~"bar")), "ETag(@~[ ~\"foo\" ], @~\"bar\")"));
-    
+
         let t = Text(@~"foo");
         let u = Section(@~[~"alpha"], true, @~[t], @~"foo", @~"foo", @~"foo", @~"foo", @~"foo");
         let v = fmt!("%?", u);    // this is the line that causes the seg fault
diff --git a/src/test/run-pass/issue-3563-3.rs b/src/test/run-pass/issue-3563-3.rs
index 9b7ab67c1a3..96925a97a10 100644
--- a/src/test/run-pass/issue-3563-3.rs
+++ b/src/test/run-pass/issue-3563-3.rs
@@ -62,7 +62,7 @@ impl Drop for AsciiArt {
 
 // It's common to define a constructor sort of function to create struct instances.
 // If there is a canonical constructor it is typically named the same as the type.
-// Other constructor sort of functions are typically named from_foo, from_bar, etc. 
+// Other constructor sort of functions are typically named from_foo, from_bar, etc.
 fn AsciiArt(width: uint, height: uint, fill: char) -> AsciiArt
 {
     // Use an anonymous function to build a vector of vectors containing
@@ -72,7 +72,7 @@ fn AsciiArt(width: uint, height: uint, fill: char) -> AsciiArt
         {
             for height.times
             {
-                let mut line = ~[];   
+                let mut line = ~[];
                 vec::grow_set(&mut line, width-1, &'.', '.');
                 push(line);
             }
@@ -208,4 +208,3 @@ pub fn main() {
     test_add_pt();
     test_shapes();
 }
-
diff --git a/src/test/run-pass/issue-3609.rs b/src/test/run-pass/issue-3609.rs
index fc6ceb4130f..6c26ac3f65e 100644
--- a/src/test/run-pass/issue-3609.rs
+++ b/src/test/run-pass/issue-3609.rs
@@ -24,4 +24,3 @@ fn foo(name: ~str, samples_chan: Chan<Msg>) {
 }
 
 pub fn main() {}
-
diff --git a/src/test/run-pass/issue-3860.rs b/src/test/run-pass/issue-3860.rs
index 46aa7187c9a..778b2b72b13 100644
--- a/src/test/run-pass/issue-3860.rs
+++ b/src/test/run-pass/issue-3860.rs
@@ -19,6 +19,6 @@ pub impl Foo {
 pub fn main() {
     let mut x = @mut Foo { x: 3 };
     // Neither of the next two lines should cause an error
-    let _ = x.stuff(); 
+    let _ = x.stuff();
     x.stuff();
 }
diff --git a/src/test/run-pass/issue-3895.rs b/src/test/run-pass/issue-3895.rs
index d3820c1e547..388e09ddb3e 100644
--- a/src/test/run-pass/issue-3895.rs
+++ b/src/test/run-pass/issue-3895.rs
@@ -11,7 +11,7 @@
 // xfail-test
 pub fn main() {
     enum State { BadChar, BadSyntax }
-    
+
     match BadChar {
         _ if true => BadChar,
         BadChar | BadSyntax => fail!() ,
diff --git a/src/test/run-pass/issue-3979-2.rs b/src/test/run-pass/issue-3979-2.rs
index c485590f4aa..a04e3510802 100644
--- a/src/test/run-pass/issue-3979-2.rs
+++ b/src/test/run-pass/issue-3979-2.rs
@@ -24,4 +24,3 @@ trait C: B {
 }
 
 pub fn main() {}
-
diff --git a/src/test/run-pass/issue-3979-generics.rs b/src/test/run-pass/issue-3979-generics.rs
index d26e9f1ba7b..57962911538 100644
--- a/src/test/run-pass/issue-3979-generics.rs
+++ b/src/test/run-pass/issue-3979-generics.rs
@@ -32,7 +32,7 @@ impl Positioned<int> for Point {
     }
 }
 
-impl Point: Movable<int, int>;
+impl Movable<int, int> for Point;
 
 pub fn main() {
     let p = Point{ x: 1, y: 2};
diff --git a/src/test/run-pass/issue-4036.rs b/src/test/run-pass/issue-4036.rs
index f24875cbf8e..8b514b11625 100644
--- a/src/test/run-pass/issue-4036.rs
+++ b/src/test/run-pass/issue-4036.rs
@@ -17,5 +17,6 @@ use self::std::serialize;
 
 pub fn main() {
     let json = json::from_str("[1]").unwrap();
-    let _x: ~[int] = serialize::Decodable::decode(&json::Decoder(json));
+    let mut decoder = json::Decoder(json);
+    let _x: ~[int] = serialize::Decodable::decode(&mut decoder);
 }
diff --git a/src/test/run-pass/issue-4241.rs b/src/test/run-pass/issue-4241.rs
index 18bc471afab..e5905e7a5be 100644
--- a/src/test/run-pass/issue-4241.rs
+++ b/src/test/run-pass/issue-4241.rs
@@ -55,7 +55,7 @@ priv fn parse_list(len: uint, io: @io::Reader) -> Result {
 priv fn chop(s: ~str) -> ~str {
   s.slice(0, s.len() - 1).to_owned()
 }
-  
+
 priv fn parse_bulk(io: @io::Reader) -> Result {
     match int::from_str(chop(io.read_line())) {
     None => fail!(),
diff --git a/src/test/run-pass/issue-4875.rs b/src/test/run-pass/issue-4875.rs
index 51c23e76808..81947791881 100644
--- a/src/test/run-pass/issue-4875.rs
+++ b/src/test/run-pass/issue-4875.rs
@@ -19,4 +19,3 @@ fn foo<T>(Foo{_}: Foo<T>) {
 
 pub fn main() {
 }
-
diff --git a/src/test/auxiliary/issue-2196-c.rs b/src/test/run-pass/issue-6117.rs
index 290267cbf32..73e9391f016 100644
--- a/src/test/auxiliary/issue-2196-c.rs
+++ b/src/test/run-pass/issue-6117.rs
@@ -1,4 +1,4 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
 //
@@ -8,7 +8,9 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use b::d;
-
-type t = uint;
-
+pub fn main() {
+    match Left(@17) {
+        Right(()) => {}
+        _ => {}
+    }
+}
diff --git a/src/test/run-pass/issue-868.rs b/src/test/run-pass/issue-868.rs
index 16e8fa18c2a..2a82f559d54 100644
--- a/src/test/run-pass/issue-868.rs
+++ b/src/test/run-pass/issue-868.rs
@@ -22,4 +22,3 @@ pub fn main() {
     let _ = f(||{});
     let _ = (||{});
 }
-
diff --git a/src/test/run-pass/issue2378c.rs b/src/test/run-pass/issue2378c.rs
index ea8c47a3eb9..98e60c56476 100644
--- a/src/test/run-pass/issue2378c.rs
+++ b/src/test/run-pass/issue2378c.rs
@@ -8,17 +8,17 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// xfail-test -- #2378 unfixed 
 // aux-build:issue2378a.rs
 // aux-build:issue2378b.rs
+// xfail-fast - check-fast doesn't understand aux-build
 
-use issue2378a;
-use issue2378b;
+extern mod issue2378a;
+extern mod issue2378b;
 
-use issue2378a::{just, methods};
-use issue2378b::{methods};
+use issue2378a::{just};
+use issue2378b::{two_maybes};
 
 pub fn main() {
-    let x = {a: just(3), b: just(5)};
+    let x = two_maybes{a: just(3), b: just(5)};
     assert!(x[0u] == (3, 5));
 }
diff --git a/src/test/run-pass/issue_3136_b.rs b/src/test/run-pass/issue_3136_b.rs
index c5b6b6b220c..b1d28a1eb67 100644
--- a/src/test/run-pass/issue_3136_b.rs
+++ b/src/test/run-pass/issue_3136_b.rs
@@ -13,4 +13,3 @@
 
 extern mod issue_3136_a;
 pub fn main() {}
-
diff --git a/src/test/run-pass/item-attributes.rs b/src/test/run-pass/item-attributes.rs
index 24fe6713372..c616d46a833 100644
--- a/src/test/run-pass/item-attributes.rs
+++ b/src/test/run-pass/item-attributes.rs
@@ -195,13 +195,3 @@ fn test_fn_inner() {
 }
 
 pub fn main() { }
-
-//
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
-//
diff --git a/src/test/run-pass/ivec-add.rs b/src/test/run-pass/ivec-add.rs
index 1b9e818421e..bd58ae65651 100644
--- a/src/test/run-pass/ivec-add.rs
+++ b/src/test/run-pass/ivec-add.rs
@@ -21,4 +21,3 @@ pub fn main() {
     assert!((d[0] == 1));
     assert!((d[1] == 1));
 }
-
diff --git a/src/test/run-pass/ivec-pass-by-value.rs b/src/test/run-pass/ivec-pass-by-value.rs
index 756f38196fd..3a3b5746b9d 100644
--- a/src/test/run-pass/ivec-pass-by-value.rs
+++ b/src/test/run-pass/ivec-pass-by-value.rs
@@ -10,4 +10,3 @@
 
 fn f(a: ~[int]) { }
 pub fn main() { f(~[1, 2, 3, 4, 5]); }
-
diff --git a/src/test/run-pass/labeled-break.rs b/src/test/run-pass/labeled-break.rs
index 06ca401a136..32cd7f0c7f8 100644
--- a/src/test/run-pass/labeled-break.rs
+++ b/src/test/run-pass/labeled-break.rs
@@ -18,4 +18,3 @@ pub fn main() {
         }
     }
 }
-
diff --git a/src/test/run-pass/let-assignability.rs b/src/test/run-pass/let-assignability.rs
index 51fa84613ca..0afc3ee87e0 100644
--- a/src/test/run-pass/let-assignability.rs
+++ b/src/test/run-pass/let-assignability.rs
@@ -17,4 +17,3 @@ fn f() {
 pub fn main() {
     f();
 }
-
diff --git a/src/test/run-pass/liveness-assign-imm-local-after-loop.rs b/src/test/run-pass/liveness-assign-imm-local-after-loop.rs
index f352a2b5273..5d59c4c1471 100644
--- a/src/test/run-pass/liveness-assign-imm-local-after-loop.rs
+++ b/src/test/run-pass/liveness-assign-imm-local-after-loop.rs
@@ -16,5 +16,5 @@ fn test(cond: bool) {
 }
 
 pub fn main() {
-	// note: don't call test()... :)
+    // note: don't call test()... :)
 }
diff --git a/src/test/run-pass/log-linearized.rs b/src/test/run-pass/log-linearized.rs
index 919c53e0330..0f388489000 100644
--- a/src/test/run-pass/log-linearized.rs
+++ b/src/test/run-pass/log-linearized.rs
@@ -32,4 +32,3 @@ fn f<T,U>() {
 pub fn main() {
     f::<int,int>();
 }
-
diff --git a/src/test/run-pass/max-min-classes.rs b/src/test/run-pass/max-min-classes.rs
index 58dcb24edf9..d986d7e676a 100644
--- a/src/test/run-pass/max-min-classes.rs
+++ b/src/test/run-pass/max-min-classes.rs
@@ -37,4 +37,3 @@ pub fn main() {
     let foo = Foo(3, 20);
     io::println(fmt!("%d %d", foo.sum(), foo.product()));
 }
-
diff --git a/src/test/run-pass/mlist-cycle.rs b/src/test/run-pass/mlist-cycle.rs
index e886c941a4b..a67f1574f64 100644
--- a/src/test/run-pass/mlist-cycle.rs
+++ b/src/test/run-pass/mlist-cycle.rs
@@ -10,16 +10,18 @@
 
 // xfail-test
 // -*- rust -*-
-extern mod std;
+extern mod core;
+use core::gc;
+use core::gc::rustrt;
 
-type cell = {c: @list};
+struct cell {c: @list}
 
 enum list { link(@mut cell), nil, }
 
 pub fn main() {
-    let first: @cell = @mut {c: @nil()};
-    let second: @cell = @mut {c: @link(first)};
+    let first: @cell = @mut cell{c: @nil()};
+    let second: @cell = @mut cell{c: @link(first)};
     first._0 = @link(second);
-    sys.rustrt.gc();
-    let third: @cell = @mut {c: @nil()};
+    rustrt::gc();
+    let third: @cell = @mut cell{c: @nil()};
 }
diff --git a/src/test/run-pass/module-qualified-struct-destructure.rs b/src/test/run-pass/module-qualified-struct-destructure.rs
index 6fb6d21f13f..87c854d32be 100644
--- a/src/test/run-pass/module-qualified-struct-destructure.rs
+++ b/src/test/run-pass/module-qualified-struct-destructure.rs
@@ -19,4 +19,3 @@ pub fn main() {
     let x = m::S { x: 1, y: 2 };
     let m::S { x: a, y: b } = x;
 }
-
diff --git a/src/test/run-pass/move-self.rs b/src/test/run-pass/move-self.rs
index d8464695728..4ed1faf65b6 100644
--- a/src/test/run-pass/move-self.rs
+++ b/src/test/run-pass/move-self.rs
@@ -16,4 +16,3 @@ pub fn main() {
     let x = S { x: ~"Hello!" };
     x.foo();
 }
-
diff --git a/src/test/run-pass/moves-based-on-type-capture-clause.rs b/src/test/run-pass/moves-based-on-type-capture-clause.rs
index 2f427ca48aa..26d4773d961 100644
--- a/src/test/run-pass/moves-based-on-type-capture-clause.rs
+++ b/src/test/run-pass/moves-based-on-type-capture-clause.rs
@@ -4,4 +4,3 @@ pub fn main() {
         io::println(x);
     }
 }
-
diff --git a/src/test/run-pass/multiple-trait-bounds.rs b/src/test/run-pass/multiple-trait-bounds.rs
index 3c6559b9c0d..cdfa93d3094 100644
--- a/src/test/run-pass/multiple-trait-bounds.rs
+++ b/src/test/run-pass/multiple-trait-bounds.rs
@@ -4,4 +4,3 @@ fn f<T:Eq + Ord>(_: T) {
 pub fn main() {
     f(3);
 }
-
diff --git a/src/test/run-pass/mut-vstore-expr.rs b/src/test/run-pass/mut-vstore-expr.rs
index 0ababc43c3f..fa6dde5b3ef 100644
--- a/src/test/run-pass/mut-vstore-expr.rs
+++ b/src/test/run-pass/mut-vstore-expr.rs
@@ -11,4 +11,3 @@
 pub fn main() {
     let x: &mut [int] = &mut [ 1, 2, 3 ];
 }
-
diff --git a/src/test/run-pass/nested-class.rs b/src/test/run-pass/nested-class.rs
index 44348223b60..83820f87d50 100644
--- a/src/test/run-pass/nested-class.rs
+++ b/src/test/run-pass/nested-class.rs
@@ -9,14 +9,13 @@
 // except according to those terms.
 
 pub fn main() {
-  
-  struct b {
-    i: int,
-  }
+    struct b {
+        i: int,
+    }
 
-  pub impl b {
-    fn do_stuff(&self) -> int { return 37; }
-  }
+    pub impl b {
+        fn do_stuff(&self) -> int { return 37; }
+    }
 
     fn b(i:int) -> b {
         b {
@@ -24,10 +23,9 @@ pub fn main() {
         }
     }
 
-  //  fn b(x:int) -> int { fail!(); }
+    //  fn b(x:int) -> int { fail!(); }
 
-  let z = b(42);
-  assert!((z.i == 42));
-  assert!((z.do_stuff() == 37));
-  
+    let z = b(42);
+    assert!((z.i == 42));
+    assert!((z.do_stuff() == 37));
 }
diff --git a/src/test/run-pass/new-impl-syntax.rs b/src/test/run-pass/new-impl-syntax.rs
index 12b41fc9148..2603353f0cf 100644
--- a/src/test/run-pass/new-impl-syntax.rs
+++ b/src/test/run-pass/new-impl-syntax.rs
@@ -23,4 +23,3 @@ pub fn main() {
     io::println(Thingy { x: 1, y: 2 }.to_str());
     io::println(PolymorphicThingy { x: Thingy { x: 1, y: 2 } }.to_str());
 }
-
diff --git a/src/test/run-pass/new-import-syntax.rs b/src/test/run-pass/new-import-syntax.rs
index 267f365c713..1390ae5f7eb 100644
--- a/src/test/run-pass/new-import-syntax.rs
+++ b/src/test/run-pass/new-import-syntax.rs
@@ -13,4 +13,3 @@ use core::io::println;
 pub fn main() {
     println("Hello world!");
 }
-
diff --git a/src/test/run-pass/new-style-constants.rs b/src/test/run-pass/new-style-constants.rs
index 9a319ea6a5c..6fe4a88d071 100644
--- a/src/test/run-pass/new-style-constants.rs
+++ b/src/test/run-pass/new-style-constants.rs
@@ -15,4 +15,3 @@ static FOO: int = 3;
 pub fn main() {
     println(fmt!("%d", FOO));
 }
-
diff --git a/src/test/run-pass/new-style-fixed-length-vec.rs b/src/test/run-pass/new-style-fixed-length-vec.rs
index 5d37a42af42..6eea23f6b2b 100644
--- a/src/test/run-pass/new-style-fixed-length-vec.rs
+++ b/src/test/run-pass/new-style-fixed-length-vec.rs
@@ -15,6 +15,3 @@ static FOO: [int, ..3] = [1, 2, 3];
 pub fn main() {
     println(fmt!("%d %d %d", FOO[0], FOO[1], FOO[2]));
 }
-
-
-
diff --git a/src/test/run-pass/new-vstore-mut-box-syntax.rs b/src/test/run-pass/new-vstore-mut-box-syntax.rs
index 971e870d1f8..63569c71982 100644
--- a/src/test/run-pass/new-vstore-mut-box-syntax.rs
+++ b/src/test/run-pass/new-vstore-mut-box-syntax.rs
@@ -12,4 +12,3 @@ pub fn main() {
     let x: @mut [int] = @mut [ 1, 2, 3 ];
 
 }
-
diff --git a/src/test/run-pass/tstate-loop-break.rs b/src/test/run-pass/newtype-struct-drop-run.rs
index 4228f72b7ca..dd5da3b09bb 100644
--- a/src/test/run-pass/tstate-loop-break.rs
+++ b/src/test/run-pass/newtype-struct-drop-run.rs
@@ -1,4 +1,4 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
 //
@@ -8,20 +8,21 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// xfail-test
+// Make sure the destructor is run for newtype structs.
 
-fn is_even(i: int) -> bool { (i%2) == 0 }
-fn even(i: int) : is_even(i) -> int { i }
+struct Foo(@mut int);
 
-fn test() {
-    let v = 4;
-    loop {
-        check is_even(v);
-        break;
+#[unsafe_destructor]
+impl Drop for Foo {
+    fn finalize(&self) {
+        ***self = 23;
     }
-    even(v);
 }
 
-pub fn main() {
-    test();
+fn main() {
+    let y = @mut 32;
+    {
+        let x = Foo(y);
+    }
+    assert_eq!(*y, 23);
 }
diff --git a/src/test/run-pass/newtype-struct-with-dtor.rs b/src/test/run-pass/newtype-struct-with-dtor.rs
index b33bfa0388a..eb3b74553b7 100644
--- a/src/test/run-pass/newtype-struct-with-dtor.rs
+++ b/src/test/run-pass/newtype-struct-with-dtor.rs
@@ -13,5 +13,3 @@ impl Drop for Fd {
 
 pub fn main() {
 }
-
-
diff --git a/src/test/run-pass/newtype-struct-xc-2.rs b/src/test/run-pass/newtype-struct-xc-2.rs
index 1fca01f7373..cedf1d42c3d 100644
--- a/src/test/run-pass/newtype-struct-xc-2.rs
+++ b/src/test/run-pass/newtype-struct-xc-2.rs
@@ -11,4 +11,3 @@ fn f() -> Au {
 pub fn main() {
     let _ = f();
 }
-
diff --git a/src/test/run-pass/newtype-struct-xc.rs b/src/test/run-pass/newtype-struct-xc.rs
index 49ce618e37b..2280b335f3f 100644
--- a/src/test/run-pass/newtype-struct-xc.rs
+++ b/src/test/run-pass/newtype-struct-xc.rs
@@ -6,4 +6,3 @@ extern mod newtype_struct_xc;
 pub fn main() {
     let _ = newtype_struct_xc::Au(2);
 }
-
diff --git a/src/test/run-pass/nullable-pointer-iotareduction.rs b/src/test/run-pass/nullable-pointer-iotareduction.rs
index 0c4d297403c..206381bcef7 100644
--- a/src/test/run-pass/nullable-pointer-iotareduction.rs
+++ b/src/test/run-pass/nullable-pointer-iotareduction.rs
@@ -20,7 +20,7 @@ use core::{option, cast};
 
 enum E<T> { Thing(int, T), Nothing((), ((), ()), [i8, ..0]) }
 impl<T> E<T> {
-    fn is_none(&self) -> bool { 
+    fn is_none(&self) -> bool {
         match *self {
             Thing(*) => false,
             Nothing(*) => true
diff --git a/src/test/run-pass/one-tuple.rs b/src/test/run-pass/one-tuple.rs
index 2efa0b98b6a..eb32e7cda1a 100644
--- a/src/test/run-pass/one-tuple.rs
+++ b/src/test/run-pass/one-tuple.rs
@@ -21,4 +21,3 @@ pub fn main() {
     let (y,) = x;
     assert!(y == 'd');
 }
-
diff --git a/src/test/run-pass/pattern-in-closure.rs b/src/test/run-pass/pattern-in-closure.rs
index 7194fca519b..08c749235c2 100644
--- a/src/test/run-pass/pattern-in-closure.rs
+++ b/src/test/run-pass/pattern-in-closure.rs
@@ -19,4 +19,3 @@ pub fn main() {
     f((2, 3));
     g(Foo { x: 1, y: 2 });
 }
-
diff --git a/src/test/run-pass/pipe-detect-term.rs b/src/test/run-pass/pipe-detect-term.rs
index bd0ffa64590..55e43075204 100644
--- a/src/test/run-pass/pipe-detect-term.rs
+++ b/src/test/run-pass/pipe-detect-term.rs
@@ -29,7 +29,7 @@ proto! oneshot (
 
 pub fn main() {
     let iotask = &uv::global_loop::get();
-    
+
     let (chan, port) = oneshot::init();
     let port = Cell(port);
     do spawn {
@@ -48,7 +48,7 @@ pub fn main() {
 fn failtest() {
     let (c, p) = oneshot::init();
 
-    do task::spawn_with(c) |_c| { 
+    do task::spawn_with(c) |_c| {
         fail!();
     }
 
diff --git a/src/test/run-pass/pipe-pingpong-bounded.rs b/src/test/run-pass/pipe-pingpong-bounded.rs
index 6d82663d195..69d87804b42 100644
--- a/src/test/run-pass/pipe-pingpong-bounded.rs
+++ b/src/test/run-pass/pipe-pingpong-bounded.rs
@@ -99,7 +99,7 @@ mod test {
         let pong(_chan) = recv(chan);
         error!("Received pong");
     }
-    
+
     pub fn server(+chan: ::pingpong::server::ping) {
         use pingpong::server;
 
diff --git a/src/test/run-pass/pipe-pingpong-proto.rs b/src/test/run-pass/pipe-pingpong-proto.rs
index 65a5672941f..d1198f3611d 100644
--- a/src/test/run-pass/pipe-pingpong-proto.rs
+++ b/src/test/run-pass/pipe-pingpong-proto.rs
@@ -37,7 +37,7 @@ mod test {
         let pong(_chan) = recv(chan);
         error!(~"Received pong");
     }
-    
+
     pub fn server(+chan: ::pingpong::server::ping) {
         use pingpong::server;
 
diff --git a/src/test/run-pass/pipe-select.rs b/src/test/run-pass/pipe-select.rs
index 12d60c9d6ab..8782f6f6ebd 100644
--- a/src/test/run-pass/pipe-select.rs
+++ b/src/test/run-pass/pipe-select.rs
@@ -55,8 +55,8 @@ pub fn main() {
     use stream::client::*;
 
     let iotask = &uv::global_loop::get();
-    
-    let c = spawn_service(stream::init, |p| { 
+
+    let c = spawn_service(stream::init, |p| {
         error!("waiting for pipes");
         let stream::send(x, p) = recv(p);
         error!("got pipes");
@@ -86,7 +86,7 @@ pub fn main() {
     let (_c2, p2) = oneshot::init();
 
     let c = send(c, (p1, p2));
-    
+
     sleep(iotask, 100);
 
     signal(c1);
diff --git a/src/test/run-pass/pipe-sleep.rs b/src/test/run-pass/pipe-sleep.rs
index 86ffc96e89a..da49a4303a6 100644
--- a/src/test/run-pass/pipe-sleep.rs
+++ b/src/test/run-pass/pipe-sleep.rs
@@ -55,6 +55,6 @@ pub fn main() {
 
     let iotask = &uv::global_loop::get();
     sleep(iotask, 500);
-    
+
     signal(c);
 }
diff --git a/src/test/run-pass/placement-new-arena.rs b/src/test/run-pass/placement-new-arena.rs
index 12c80421932..166435cbc3d 100644
--- a/src/test/run-pass/placement-new-arena.rs
+++ b/src/test/run-pass/placement-new-arena.rs
@@ -14,7 +14,8 @@ extern mod std;
 use std::arena;
 
 pub fn main() {
-    let p = &arena::Arena();
+    let mut arena = arena::Arena();
+    let p = &mut arena;
     let x = p.alloc(|| 4u);
     io::print(fmt!("%u", *x));
     assert!(*x == 4u);
diff --git a/src/test/run-pass/preempt.rs b/src/test/run-pass/preempt.rs
index e0434c14048..3d3e178f064 100644
--- a/src/test/run-pass/preempt.rs
+++ b/src/test/run-pass/preempt.rs
@@ -13,7 +13,7 @@
 
 fn starve_main(alive: chan<int>) {
     debug!("signalling main");
-    alive <| 1;
+    alive.recv(1);
     debug!("starving main");
     let i: int = 0;
     loop { i += 1; }
@@ -22,10 +22,12 @@ fn starve_main(alive: chan<int>) {
 pub fn main() {
     let alive: port<int> = port();
     debug!("main started");
-    let s: task = spawn starve_main(chan(alive));
+    let s: task = do task::spawn {
+        starve_main(chan(alive));
+    };
     let i: int;
     debug!("main waiting for alive signal");
-    alive |> i;
+    alive.send(i);
     debug!("main got alive signal");
     while i < 50 { debug!("main iterated"); i += 1; }
     debug!("main completed");
diff --git a/src/test/run-pass/pub-use-xcrate.rs b/src/test/run-pass/pub-use-xcrate.rs
index 03004e5e475..74ae81e63e2 100644
--- a/src/test/run-pass/pub-use-xcrate.rs
+++ b/src/test/run-pass/pub-use-xcrate.rs
@@ -21,4 +21,3 @@ pub fn main() {
         name: 0
     };
 }
-
diff --git a/src/test/run-pass/pub_use_mods_xcrate_exe.rs b/src/test/run-pass/pub_use_mods_xcrate_exe.rs
index 1d60cab3a82..953a99e1fd5 100644
--- a/src/test/run-pass/pub_use_mods_xcrate_exe.rs
+++ b/src/test/run-pass/pub_use_mods_xcrate_exe.rs
@@ -15,4 +15,3 @@ extern mod pub_use_mods_xcrate;
 use pub_use_mods_xcrate::a::c;
 
 pub fn main(){}
-
diff --git a/src/test/run-pass/reexport-star.rs b/src/test/run-pass/reexport-star.rs
index 3b9fe688d4d..3cc250b1707 100644
--- a/src/test/run-pass/reexport-star.rs
+++ b/src/test/run-pass/reexport-star.rs
@@ -25,4 +25,3 @@ pub fn main() {
     b::f();
     b::g();
 }
-
diff --git a/src/test/run-pass/regions-addr-of-interior-of-unique-box.rs b/src/test/run-pass/regions-addr-of-interior-of-unique-box.rs
index 1fb9c126e74..7efe62236f3 100644
--- a/src/test/run-pass/regions-addr-of-interior-of-unique-box.rs
+++ b/src/test/run-pass/regions-addr-of-interior-of-unique-box.rs
@@ -26,4 +26,3 @@ fn get_x<'r>(x: &'r Character) -> &'r int {
 
 pub fn main() {
 }
-
diff --git a/src/test/run-pass/regions-addr-of-ret.rs b/src/test/run-pass/regions-addr-of-ret.rs
index a9c65d01295..9e19618f332 100644
--- a/src/test/run-pass/regions-addr-of-ret.rs
+++ b/src/test/run-pass/regions-addr-of-ret.rs
@@ -16,4 +16,3 @@ pub fn main() {
     let three = &3;
     error!(fmt!("%d", *f(three)));
 }
-
diff --git a/src/test/run-pass/regions-fn-subtyping-2.rs b/src/test/run-pass/regions-fn-subtyping-2.rs
index a995b3d9693..ef8d9970c2b 100644
--- a/src/test/run-pass/regions-fn-subtyping-2.rs
+++ b/src/test/run-pass/regions-fn-subtyping-2.rs
@@ -8,23 +8,19 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// xfail-test
-
 // Issue #2263.
 
 // Here, `f` is a function that takes a pointer `x` and a function
 // `g`, where `g` requires its argument `y` to be in the same region
 // that `x` is in.
-fn has_same_region(f: &fn(x: &a.int, g: &fn(y: &a.int))) {
+fn has_same_region(f: &fn<'a>(x: &'a int, g: &fn(y: &'a int))) {
     // `f` should be the type that `wants_same_region` wants, but
     // right now the compiler complains that it isn't.
     wants_same_region(f);
 }
 
-fn wants_same_region(_f: &fn(x: &b.int, g: &fn(y: &b.int))) { 
+fn wants_same_region(_f: &fn<'b>(x: &'b int, g: &fn(y: &'b int))) {
 }
 
 pub fn main() {
 }
-
-
diff --git a/src/test/run-pass/regions-infer-borrow-scope-addr-of.rs b/src/test/run-pass/regions-infer-borrow-scope-addr-of.rs
index ee2682ff4ab..39da08de6df 100644
--- a/src/test/run-pass/regions-infer-borrow-scope-addr-of.rs
+++ b/src/test/run-pass/regions-infer-borrow-scope-addr-of.rs
@@ -13,15 +13,15 @@ pub fn main() {
 
     for uint::range(0, 3) |i| {
         // ensure that the borrow in this alt
-	// does not inferfere with the swap
-	// below.  note that it would it you
-	// naively borrowed &x for the lifetime
-	// of the variable x, as we once did
+        // does not inferfere with the swap
+        // below.  note that it would it you
+        // naively borrowed &x for the lifetime
+        // of the variable x, as we once did
         match i {
-          i => {
-            let y = &x;
-            assert!(i < *y);
-          }
+            i => {
+                let y = &x;
+                assert!(i < *y);
+            }
         }
         let mut y = 4;
         y <-> x;
diff --git a/src/test/run-pass/regions-infer-borrow-scope-view.rs b/src/test/run-pass/regions-infer-borrow-scope-view.rs
index 9358ea8a777..8f7452f2d06 100644
--- a/src/test/run-pass/regions-infer-borrow-scope-view.rs
+++ b/src/test/run-pass/regions-infer-borrow-scope-view.rs
@@ -16,4 +16,3 @@ pub fn main() {
     let y = view(x);
     assert!((v[0] == x[0]) && (v[0] == y[0]));
 }
-
diff --git a/src/test/run-pass/regions-infer-borrow-scope-within-loop-ok.rs b/src/test/run-pass/regions-infer-borrow-scope-within-loop-ok.rs
index 08c54c790b1..73535f52043 100644
--- a/src/test/run-pass/regions-infer-borrow-scope-within-loop-ok.rs
+++ b/src/test/run-pass/regions-infer-borrow-scope-within-loop-ok.rs
@@ -15,6 +15,6 @@ pub fn main() {
     loop {
         let y = borrow(x);
         assert!(*x == *y);
-	break;
+        break;
     }
 }
diff --git a/src/test/run-pass/regions-infer-borrow-scope.rs b/src/test/run-pass/regions-infer-borrow-scope.rs
index e06a2fea1c1..61b9000aea3 100644
--- a/src/test/run-pass/regions-infer-borrow-scope.rs
+++ b/src/test/run-pass/regions-infer-borrow-scope.rs
@@ -19,4 +19,3 @@ pub fn main() {
     let xc = x_coord(p);
     assert!(*xc == 3);
 }
-
diff --git a/src/test/run-pass/regions-mock-trans-impls.rs b/src/test/run-pass/regions-mock-trans-impls.rs
index c1f7a713ca6..d54aae7bb63 100644
--- a/src/test/run-pass/regions-mock-trans-impls.rs
+++ b/src/test/run-pass/regions-mock-trans-impls.rs
@@ -21,7 +21,7 @@ struct Bcx<'self> {
 }
 
 struct Fcx<'self> {
-    arena: &'self Arena,
+    arena: &'self mut Arena,
     ccx: &'self Ccx
 }
 
@@ -29,23 +29,26 @@ struct Ccx {
     x: int
 }
 
-fn h<'r>(bcx : &'r Bcx<'r>) -> &'r Bcx<'r> {
-    return bcx.fcx.arena.alloc(|| Bcx { fcx: bcx.fcx });
+fn h<'r>(bcx : &'r mut Bcx<'r>) -> &'r mut Bcx<'r> {
+    // XXX: Arena has a bad interface here; it should return mutable pointers.
+    // But this patch is too big to roll that in.
+    unsafe {
+        cast::transmute(bcx.fcx.arena.alloc(|| Bcx { fcx: bcx.fcx }))
+    }
 }
 
-fn g(fcx : &Fcx) {
-    let bcx = Bcx { fcx: fcx };
-    h(&bcx);
+fn g(fcx: &mut Fcx) {
+    let mut bcx = Bcx { fcx: fcx };
+    h(&mut bcx);
 }
 
-fn f(ccx : &Ccx) {
-    let a = Arena();
-    let fcx = &Fcx { arena: &a, ccx: ccx };
-    return g(fcx);
+fn f(ccx: &mut Ccx) {
+    let mut a = Arena();
+    let mut fcx = Fcx { arena: &mut a, ccx: ccx };
+    return g(&mut fcx);
 }
 
 pub fn main() {
-    let ccx = Ccx { x: 0 };
-    f(&ccx);
+    let mut ccx = Ccx { x: 0 };
+    f(&mut ccx);
 }
-
diff --git a/src/test/run-pass/regions-mock-trans.rs b/src/test/run-pass/regions-mock-trans.rs
index c46e41ab0eb..0ea6f852a89 100644
--- a/src/test/run-pass/regions-mock-trans.rs
+++ b/src/test/run-pass/regions-mock-trans.rs
@@ -52,4 +52,3 @@ pub fn main() {
     let ccx = Ccx { x: 0 };
     f(&ccx);
 }
-
diff --git a/src/test/run-pass/regions-self-impls.rs b/src/test/run-pass/regions-self-impls.rs
index 2f4eefe5243..c43fd0db566 100644
--- a/src/test/run-pass/regions-self-impls.rs
+++ b/src/test/run-pass/regions-self-impls.rs
@@ -25,4 +25,3 @@ pub fn main() {
     debug!(*clam.get_chowder());
     clam.get_chowder();
 }
-
diff --git a/src/test/run-pass/regions-self-in-enums.rs b/src/test/run-pass/regions-self-in-enums.rs
index 78045e5e5d4..5f8b9ee3332 100644
--- a/src/test/run-pass/regions-self-in-enums.rs
+++ b/src/test/run-pass/regions-self-in-enums.rs
@@ -21,4 +21,3 @@ pub fn main() {
     }
     debug!(*z);
 }
-
diff --git a/src/test/run-pass/regions-simple.rs b/src/test/run-pass/regions-simple.rs
index f7a50e6b114..436fede4dc1 100644
--- a/src/test/run-pass/regions-simple.rs
+++ b/src/test/run-pass/regions-simple.rs
@@ -14,5 +14,3 @@ pub fn main() {
     *y = 5;
     debug!(*y);
 }
-
-
diff --git a/src/test/run-pass/repeated-vector-syntax.rs b/src/test/run-pass/repeated-vector-syntax.rs
index a22384a6b53..f3d6c1640d8 100644
--- a/src/test/run-pass/repeated-vector-syntax.rs
+++ b/src/test/run-pass/repeated-vector-syntax.rs
@@ -21,4 +21,3 @@ pub fn main() {
     error!("%?", x);
     error!("%?", y);
 }
-
diff --git a/src/test/run-pass/resource-cycle.rs b/src/test/run-pass/resource-cycle.rs
index fdb8c2a496c..f498553834a 100644
--- a/src/test/run-pass/resource-cycle.rs
+++ b/src/test/run-pass/resource-cycle.rs
@@ -57,7 +57,7 @@ pub fn main() {
               debug!("r = %x", cast::transmute::<*r, uint>(&rs));
               rs }
         });
-        
+
         debug!("x1 = %x, x1.r = %x",
                cast::transmute::<@mut t, uint>(x1),
                cast::transmute::<*r, uint>(&x1.r));
@@ -70,7 +70,7 @@ pub fn main() {
               rs
                 }
         });
-        
+
         debug!("x2 = %x, x2.r = %x",
                cast::transmute::<@mut t, uint>(x2),
                cast::transmute::<*r, uint>(&(x2.r)));
diff --git a/src/test/run-pass/resource-cycle3.rs b/src/test/run-pass/resource-cycle3.rs
index 0d699a6e49b..ef713724778 100644
--- a/src/test/run-pass/resource-cycle3.rs
+++ b/src/test/run-pass/resource-cycle3.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// same as resource-cycle2, but be sure to give r multiple fields... 
+// same as resource-cycle2, but be sure to give r multiple fields...
 
 // Don't leak the unique pointers
 
@@ -50,7 +50,7 @@ struct Node {
     r: R
 }
 
-pub fn main() { 
+pub fn main() {
     unsafe {
         let i1 = ~0xA;
         let i1p = cast::transmute_copy(&i1);
diff --git a/src/test/run-pass/self-type-param.rs b/src/test/run-pass/self-type-param.rs
index 0af19796804..d90ec51bedf 100644
--- a/src/test/run-pass/self-type-param.rs
+++ b/src/test/run-pass/self-type-param.rs
@@ -13,4 +13,3 @@ impl MyTrait for S {
 }
 
 pub fn main() {}
-
diff --git a/src/test/run-pass/spawn.rs b/src/test/run-pass/spawn.rs
index db4ca7b3ed8..63c2b7da38f 100644
--- a/src/test/run-pass/spawn.rs
+++ b/src/test/run-pass/spawn.rs
@@ -18,11 +18,3 @@ pub fn main() {
 }
 
 fn child(&&i: int) { error!(i); assert!((i == 10)); }
-
-// Local Variables:
-// mode: rust;
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
diff --git a/src/test/run-pass/spawn2.rs b/src/test/run-pass/spawn2.rs
index f9350746349..e748a1636ea 100644
--- a/src/test/run-pass/spawn2.rs
+++ b/src/test/run-pass/spawn2.rs
@@ -32,11 +32,3 @@ fn child(&&args: (int, int, int, int, int, int, int, int, int)) {
     assert!((i8 == 80));
     assert!((i9 == 90));
 }
-
-// Local Variables:
-// mode: rust;
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
diff --git a/src/test/run-pass/static-methods-in-traits.rs b/src/test/run-pass/static-methods-in-traits.rs
index d171434aa48..42d0f02d642 100644
--- a/src/test/run-pass/static-methods-in-traits.rs
+++ b/src/test/run-pass/static-methods-in-traits.rs
@@ -9,27 +9,26 @@
 // except according to those terms.
 
 mod a {
-	pub trait Foo {
-		pub fn foo() -> Self;
-	}
+    pub trait Foo {
+        pub fn foo() -> Self;
+    }
 
-	impl Foo for int {
-		pub fn foo() -> int {
-			3
-		}
-	}
-	
-	impl Foo for uint {
-		pub fn foo() -> uint {
-			5u
-		}
-	}
+    impl Foo for int {
+        pub fn foo() -> int {
+            3
+        }
+    }
+
+    impl Foo for uint {
+        pub fn foo() -> uint {
+            5u
+        }
+    }
 }
 
 pub fn main() {
-	let x: int = a::Foo::foo();
-	let y: uint = a::Foo::foo();
-	assert!(x == 3);
-	assert!(y == 5);
+    let x: int = a::Foo::foo();
+    let y: uint = a::Foo::foo();
+    assert!(x == 3);
+    assert!(y == 5);
 }
-
diff --git a/src/test/run-pass/struct-deref.rs b/src/test/run-pass/struct-deref.rs
index f71bc06a1cf..a52a2851689 100644
--- a/src/test/run-pass/struct-deref.rs
+++ b/src/test/run-pass/struct-deref.rs
@@ -14,4 +14,3 @@ pub fn main() {
     let x: Foo = Foo(2);
     assert!(*x == 2);
 }
-
diff --git a/src/test/run-pass/struct-field-assignability.rs b/src/test/run-pass/struct-field-assignability.rs
index 1e13c7b86bf..0aca1a3d05f 100644
--- a/src/test/run-pass/struct-field-assignability.rs
+++ b/src/test/run-pass/struct-field-assignability.rs
@@ -6,4 +6,3 @@ pub fn main() {
     let f = Foo { x: @3 };
     assert!(*f.x == 3);
 }
-
diff --git a/src/test/run-pass/struct-like-variant-construct.rs b/src/test/run-pass/struct-like-variant-construct.rs
index 0d14d90c1f1..bc2dce680c9 100644
--- a/src/test/run-pass/struct-like-variant-construct.rs
+++ b/src/test/run-pass/struct-like-variant-construct.rs
@@ -22,4 +22,3 @@ enum Foo {
 pub fn main() {
     let x = Bar { a: 2, b: 3 };
 }
-
diff --git a/src/test/run-pass/struct-like-variant-match.rs b/src/test/run-pass/struct-like-variant-match.rs
index 3158d2836dd..64a75ddab22 100644
--- a/src/test/run-pass/struct-like-variant-match.rs
+++ b/src/test/run-pass/struct-like-variant-match.rs
@@ -38,4 +38,3 @@ pub fn main() {
     let y = Baz { x: 1.0, y: 2.0 };
     f(&y);
 }
-
diff --git a/src/test/run-pass/struct-pattern-matching.rs b/src/test/run-pass/struct-pattern-matching.rs
index 1d7bcb2585f..1bda2d2412d 100644
--- a/src/test/run-pass/struct-pattern-matching.rs
+++ b/src/test/run-pass/struct-pattern-matching.rs
@@ -19,6 +19,3 @@ pub fn main() {
         Foo { x: x, y: y } => io::println(fmt!("yes, %d, %d", x, y))
     }
 }
-
-
-
diff --git a/src/test/run-pass/super.rs b/src/test/run-pass/super.rs
index 2fe0696b2f2..b5eb6e85045 100644
--- a/src/test/run-pass/super.rs
+++ b/src/test/run-pass/super.rs
@@ -9,4 +9,3 @@ pub mod a {
 
 pub fn main() {
 }
-
diff --git a/src/test/run-pass/tag-align-dyn-u64.rs b/src/test/run-pass/tag-align-dyn-u64.rs
index a9c59de49ee..a09ee23f147 100644
--- a/src/test/run-pass/tag-align-dyn-u64.rs
+++ b/src/test/run-pass/tag-align-dyn-u64.rs
@@ -10,25 +10,25 @@
 
 // xfail-test
 
-tag a_tag<A> {
-    a_tag(A);
+enum a_tag<A> {
+    a_tag(A)
 }
 
-type t_rec = {
+struct t_rec {
     c8: u8,
     t: a_tag<u64>
-};
+}
 
 fn mk_rec() -> t_rec {
-    return { c8:0u8, t:a_tag(0u64) };
+    return t_rec { c8:0u8, t:a_tag(0u64) };
 }
 
-fn is_8_byte_aligned(&&u: a_tag<u64>) -> bool {
+fn is_8_byte_aligned(u: &a_tag<u64>) -> bool {
     let p = ptr::to_unsafe_ptr(u) as uint;
     return (p & 7u) == 0u;
 }
 
 pub fn main() {
     let x = mk_rec();
-    assert!(is_8_byte_aligned(x.t));
+    assert!(is_8_byte_aligned(&x.t));
 }
diff --git a/src/test/run-pass/tag-align-dyn-variants.rs b/src/test/run-pass/tag-align-dyn-variants.rs
index 4fc6410f8f3..cd94bd30c21 100644
--- a/src/test/run-pass/tag-align-dyn-variants.rs
+++ b/src/test/run-pass/tag-align-dyn-variants.rs
@@ -10,62 +10,62 @@
 
 // xfail-test
 
-tag a_tag<A,B> {
-    varA(A);
-    varB(B);
+enum a_tag<A,B> {
+    varA(A),
+    varB(B)
 }
 
-type t_rec<A,B> = {
+struct t_rec<A,B> {
     chA: u8,
     tA: a_tag<A,B>,
     chB: u8,
     tB: a_tag<A,B>
-};
+}
 
-fn mk_rec<A:copy,B:copy>(a: A, b: B) -> t_rec<A,B> {
-    return { chA:0u8, tA:varA(a), chB:1u8, tB:varB(b) };
+fn mk_rec<A:Copy,B:Copy>(a: A, b: B) -> t_rec<A,B> {
+    return t_rec{ chA:0u8, tA:varA(a), chB:1u8, tB:varB(b) };
 }
 
-fn is_aligned<A>(amnt: uint, &&u: A) -> bool {
+fn is_aligned<A>(amnt: uint, u: &A) -> bool {
     let p = ptr::to_unsafe_ptr(u) as uint;
     return (p & (amnt-1u)) == 0u;
 }
 
-fn variant_data_is_aligned<A,B>(amnt: uint, &&u: a_tag<A,B>) -> bool {
+fn variant_data_is_aligned<A,B>(amnt: uint, u: &a_tag<A,B>) -> bool {
     match u {
-      varA(a) { is_aligned(amnt, a) }
-      varB(b) { is_aligned(amnt, b) }
+      &varA(ref a) => is_aligned(amnt, a),
+      &varB(ref b) => is_aligned(amnt, b)
     }
 }
 
 pub fn main() {
     let x = mk_rec(22u64, 23u64);
-    assert!(is_aligned(8u, x.tA));
-    assert!(variant_data_is_aligned(8u, x.tA));
-    assert!(is_aligned(8u, x.tB));
-    assert!(variant_data_is_aligned(8u, x.tB));
+    assert!(is_aligned(8u, &x.tA));
+    assert!(variant_data_is_aligned(8u, &x.tA));
+    assert!(is_aligned(8u, &x.tB));
+    assert!(variant_data_is_aligned(8u, &x.tB));
 
     let x = mk_rec(22u64, 23u32);
-    assert!(is_aligned(8u, x.tA));
-    assert!(variant_data_is_aligned(8u, x.tA));
-    assert!(is_aligned(8u, x.tB));
-    assert!(variant_data_is_aligned(4u, x.tB));
+    assert!(is_aligned(8u, &x.tA));
+    assert!(variant_data_is_aligned(8u, &x.tA));
+    assert!(is_aligned(8u, &x.tB));
+    assert!(variant_data_is_aligned(4u, &x.tB));
 
     let x = mk_rec(22u32, 23u64);
-    assert!(is_aligned(8u, x.tA));
-    assert!(variant_data_is_aligned(4u, x.tA));
-    assert!(is_aligned(8u, x.tB));
-    assert!(variant_data_is_aligned(8u, x.tB));
+    assert!(is_aligned(8u, &x.tA));
+    assert!(variant_data_is_aligned(4u, &x.tA));
+    assert!(is_aligned(8u, &x.tB));
+    assert!(variant_data_is_aligned(8u, &x.tB));
 
     let x = mk_rec(22u32, 23u32);
-    assert!(is_aligned(4u, x.tA));
-    assert!(variant_data_is_aligned(4u, x.tA));
-    assert!(is_aligned(4u, x.tB));
-    assert!(variant_data_is_aligned(4u, x.tB));
+    assert!(is_aligned(4u, &x.tA));
+    assert!(variant_data_is_aligned(4u, &x.tA));
+    assert!(is_aligned(4u, &x.tB));
+    assert!(variant_data_is_aligned(4u, &x.tB));
 
     let x = mk_rec(22f64, 23f64);
-    assert!(is_aligned(8u, x.tA));
-    assert!(variant_data_is_aligned(8u, x.tA));
-    assert!(is_aligned(8u, x.tB));
-    assert!(variant_data_is_aligned(8u, x.tB));
+    assert!(is_aligned(8u, &x.tA));
+    assert!(variant_data_is_aligned(8u, &x.tA));
+    assert!(is_aligned(8u, &x.tB));
+    assert!(variant_data_is_aligned(8u, &x.tB));
 }
diff --git a/src/test/run-pass/tag-align-shape.rs b/src/test/run-pass/tag-align-shape.rs
index 052bacad7ce..43a793a34c8 100644
--- a/src/test/run-pass/tag-align-shape.rs
+++ b/src/test/run-pass/tag-align-shape.rs
@@ -8,22 +8,18 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// xfail-test
-//
-// See issue #1535
-
-tag a_tag {
-    a_tag(u64);
+enum a_tag {
+    a_tag(u64)
 }
 
-type t_rec = {
+struct t_rec {
     c8: u8,
     t: a_tag
-};
+}
 
 pub fn main() {
-    let x = {c8: 22u8, t: a_tag(44u64)};
+    let x = t_rec {c8: 22u8, t: a_tag(44u64)};
     let y = fmt!("%?", x);
     debug!("y = %s", y);
-    assert!(y == "(22, a_tag(44))");
+    assert_eq!(y, ~"{c8: 22, t: a_tag(44)}");
 }
diff --git a/src/test/run-pass/tag-align-u64.rs b/src/test/run-pass/tag-align-u64.rs
index fd96d7d0242..ea60f389663 100644
--- a/src/test/run-pass/tag-align-u64.rs
+++ b/src/test/run-pass/tag-align-u64.rs
@@ -10,25 +10,25 @@
 
 // xfail-test
 
-tag a_tag {
-    a_tag(u64);
+enum a_tag {
+    a_tag(u64)
 }
 
-type t_rec = {
+struct t_rec {
     c8: u8,
     t: a_tag
-};
+}
 
 fn mk_rec() -> t_rec {
-    return { c8:0u8, t:a_tag(0u64) };
+    return t_rec { c8:0u8, t:a_tag(0u64) };
 }
 
-fn is_8_byte_aligned(&&u: a_tag) -> bool {
+fn is_8_byte_aligned(u: &a_tag) -> bool {
     let p = ptr::to_unsafe_ptr(u) as u64;
     return (p & 7u64) == 0u64;
 }
 
 pub fn main() {
     let x = mk_rec();
-    assert!(is_8_byte_aligned(x.t));
+    assert!(is_8_byte_aligned(&x.t));
 }
diff --git a/src/test/run-pass/tag-disr-val-shape.rs b/src/test/run-pass/tag-disr-val-shape.rs
index 50ab17fdeea..dd78dff0d6e 100644
--- a/src/test/run-pass/tag-disr-val-shape.rs
+++ b/src/test/run-pass/tag-disr-val-shape.rs
@@ -23,4 +23,3 @@ pub fn main() {
     assert!(~"green" == fmt!("%?", green));
     assert!(~"white" == fmt!("%?", white));
 }
-
diff --git a/src/test/run-pass/tag-variant-disr-val.rs b/src/test/run-pass/tag-variant-disr-val.rs
index 0806f1ea92a..d4eadd366de 100644
--- a/src/test/run-pass/tag-variant-disr-val.rs
+++ b/src/test/run-pass/tag-variant-disr-val.rs
@@ -69,5 +69,3 @@ fn get_color_if(color: color) -> ~str {
     else if color == orange {~"orange"}
     else {~"unknown"}
 }
-
-
diff --git a/src/test/run-pass/task-killjoin-rsrc.rs b/src/test/run-pass/task-killjoin-rsrc.rs
index 7cd08695da0..879f668577f 100644
--- a/src/test/run-pass/task-killjoin-rsrc.rs
+++ b/src/test/run-pass/task-killjoin-rsrc.rs
@@ -83,11 +83,3 @@ fn supervisor() {
 pub fn main() {
     join(joinable(supervisor));
 }
-
-// Local Variables:
-// mode: rust;
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
diff --git a/src/test/run-pass/task-killjoin.rs b/src/test/run-pass/task-killjoin.rs
index 563e35be3d6..73c069e560c 100644
--- a/src/test/run-pass/task-killjoin.rs
+++ b/src/test/run-pass/task-killjoin.rs
@@ -33,11 +33,3 @@ fn supervisor() {
 pub fn main() {
     task::spawn_unlinked(supervisor)
 }
-
-// Local Variables:
-// mode: rust;
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
diff --git a/src/test/run-pass/threads.rs b/src/test/run-pass/threads.rs
index f736ded3db2..288a23b855b 100644
--- a/src/test/run-pass/threads.rs
+++ b/src/test/run-pass/threads.rs
@@ -19,4 +19,3 @@ pub fn main() {
 }
 
 fn child(&&x: int) { debug!(x); }
-
diff --git a/src/test/run-pass/trait-composition-trivial.rs b/src/test/run-pass/trait-composition-trivial.rs
index 328c0b6888c..de130bf1b41 100644
--- a/src/test/run-pass/trait-composition-trivial.rs
+++ b/src/test/run-pass/trait-composition-trivial.rs
@@ -17,5 +17,3 @@ trait Bar : Foo {
 }
 
 pub fn main() {}
-
-
diff --git a/src/test/run-pass/trait-inheritance-auto-xc-2.rs b/src/test/run-pass/trait-inheritance-auto-xc-2.rs
index 446dd4b3d8e..996f55d4019 100644
--- a/src/test/run-pass/trait-inheritance-auto-xc-2.rs
+++ b/src/test/run-pass/trait-inheritance-auto-xc-2.rs
@@ -30,4 +30,3 @@ pub fn main() {
     let a = &A { x: 3 };
     f(a);
 }
-
diff --git a/src/test/run-pass/trait-inheritance-auto-xc.rs b/src/test/run-pass/trait-inheritance-auto-xc.rs
index 03287809a9b..3af8d606bf4 100644
--- a/src/test/run-pass/trait-inheritance-auto-xc.rs
+++ b/src/test/run-pass/trait-inheritance-auto-xc.rs
@@ -31,4 +31,3 @@ pub fn main() {
     let a = &A { x: 3 };
     f(a);
 }
-
diff --git a/src/test/run-pass/trait-inheritance-auto.rs b/src/test/run-pass/trait-inheritance-auto.rs
index b74064591d3..fb97dd5e774 100644
--- a/src/test/run-pass/trait-inheritance-auto.rs
+++ b/src/test/run-pass/trait-inheritance-auto.rs
@@ -34,4 +34,3 @@ pub fn main() {
     let a = &A { x: 3 };
     f(a);
 }
-
diff --git a/src/test/run-pass/trait-inheritance-call-bound-inherited.rs b/src/test/run-pass/trait-inheritance-call-bound-inherited.rs
index 26b96f93326..805c9655d81 100644
--- a/src/test/run-pass/trait-inheritance-call-bound-inherited.rs
+++ b/src/test/run-pass/trait-inheritance-call-bound-inherited.rs
@@ -25,4 +25,3 @@ pub fn main() {
     let a = &A { x: 3 };
     assert!(gg(a) == 10);
 }
-
diff --git a/src/test/run-pass/trait-inheritance-call-bound-inherited2.rs b/src/test/run-pass/trait-inheritance-call-bound-inherited2.rs
index 5e612bbca64..0b35fd90bbd 100644
--- a/src/test/run-pass/trait-inheritance-call-bound-inherited2.rs
+++ b/src/test/run-pass/trait-inheritance-call-bound-inherited2.rs
@@ -28,4 +28,3 @@ pub fn main() {
     let a = &A { x: 3 };
     assert!(gg(a) == 10);
 }
-
diff --git a/src/test/run-pass/trait-inheritance-cast-without-call-to-supertrait.rs b/src/test/run-pass/trait-inheritance-cast-without-call-to-supertrait.rs
index 6efd854e01b..df9cc4fb8b6 100644
--- a/src/test/run-pass/trait-inheritance-cast-without-call-to-supertrait.rs
+++ b/src/test/run-pass/trait-inheritance-cast-without-call-to-supertrait.rs
@@ -38,4 +38,3 @@ pub fn main() {
     assert!(afoo.f() == 10);
     assert!(abar.g() == 20);
 }
-
diff --git a/src/test/run-pass/trait-inheritance-cast.rs b/src/test/run-pass/trait-inheritance-cast.rs
index 02382797797..75c121e10b0 100644
--- a/src/test/run-pass/trait-inheritance-cast.rs
+++ b/src/test/run-pass/trait-inheritance-cast.rs
@@ -40,4 +40,3 @@ pub fn main() {
     assert!(abar.g() == 20);
     assert!(abar.f() == 10);
 }
-
diff --git a/src/test/run-pass/trait-inheritance-cross-trait-call-xc.rs b/src/test/run-pass/trait-inheritance-cross-trait-call-xc.rs
index 3c1bf2035aa..976c9a02439 100644
--- a/src/test/run-pass/trait-inheritance-cross-trait-call-xc.rs
+++ b/src/test/run-pass/trait-inheritance-cross-trait-call-xc.rs
@@ -27,4 +27,3 @@ pub fn main() {
     let a = &aux::A { x: 3 };
     assert!(a.g() == 10);
 }
-
diff --git a/src/test/run-pass/trait-inheritance-cross-trait-call.rs b/src/test/run-pass/trait-inheritance-cross-trait-call.rs
index 997f13d0e5e..20dac16b492 100644
--- a/src/test/run-pass/trait-inheritance-cross-trait-call.rs
+++ b/src/test/run-pass/trait-inheritance-cross-trait-call.rs
@@ -24,4 +24,3 @@ pub fn main() {
     let a = &A { x: 3 };
     assert!(a.g() == 10);
 }
-
diff --git a/src/test/run-pass/trait-inheritance-overloading-simple.rs b/src/test/run-pass/trait-inheritance-overloading-simple.rs
index 711571e8c64..3a1c3716df4 100644
--- a/src/test/run-pass/trait-inheritance-overloading-simple.rs
+++ b/src/test/run-pass/trait-inheritance-overloading-simple.rs
@@ -32,4 +32,3 @@ pub fn main() {
     assert!(x != y);
     assert!(x == z);
 }
-
diff --git a/src/test/run-pass/trait-inheritance-overloading-xc-exe.rs b/src/test/run-pass/trait-inheritance-overloading-xc-exe.rs
index 9f745db7638..d89852e2b05 100644
--- a/src/test/run-pass/trait-inheritance-overloading-xc-exe.rs
+++ b/src/test/run-pass/trait-inheritance-overloading-xc-exe.rs
@@ -27,4 +27,3 @@ pub fn main() {
     assert!(b == mi(-2));
     assert!(c == mi(15));
 }
-
diff --git a/src/test/run-pass/trait-inheritance-overloading.rs b/src/test/run-pass/trait-inheritance-overloading.rs
index 5b68aff269e..e58ec24f1b7 100644
--- a/src/test/run-pass/trait-inheritance-overloading.rs
+++ b/src/test/run-pass/trait-inheritance-overloading.rs
@@ -46,4 +46,3 @@ pub fn main() {
     assert!(b == mi(-2));
     assert!(c == mi(15));
 }
-
diff --git a/src/test/run-pass/trait-inheritance-self.rs b/src/test/run-pass/trait-inheritance-self.rs
index 02ed518ff65..5eb87b7a96b 100644
--- a/src/test/run-pass/trait-inheritance-self.rs
+++ b/src/test/run-pass/trait-inheritance-self.rs
@@ -26,4 +26,3 @@ pub fn main() {
     let s = S { x: 1 };
     s.g();
 }
-
diff --git a/src/test/run-pass/trait-inheritance-simple.rs b/src/test/run-pass/trait-inheritance-simple.rs
index 779dfb65944..2da1f02779e 100644
--- a/src/test/run-pass/trait-inheritance-simple.rs
+++ b/src/test/run-pass/trait-inheritance-simple.rs
@@ -29,4 +29,3 @@ pub fn main() {
     assert!(ff(a) == 10);
     assert!(gg(a) == 20);
 }
-
diff --git a/src/test/run-pass/trait-inheritance-subst.rs b/src/test/run-pass/trait-inheritance-subst.rs
index 22efdabec83..479f293a396 100644
--- a/src/test/run-pass/trait-inheritance-subst.rs
+++ b/src/test/run-pass/trait-inheritance-subst.rs
@@ -33,4 +33,3 @@ pub fn main() {
     let z = f(x, y);
     assert!(z.val == 8)
 }
-
diff --git a/src/test/run-pass/trait-inheritance-subst2.rs b/src/test/run-pass/trait-inheritance-subst2.rs
index 4f3b808f8eb..5d1741a45f3 100644
--- a/src/test/run-pass/trait-inheritance-subst2.rs
+++ b/src/test/run-pass/trait-inheritance-subst2.rs
@@ -43,4 +43,3 @@ pub fn main() {
     let z = f(x, y);
     assert!(z.val == 13);
 }
-
diff --git a/src/test/run-pass/trait-inheritance2.rs b/src/test/run-pass/trait-inheritance2.rs
index 5d6913d4146..adb7ab018d6 100644
--- a/src/test/run-pass/trait-inheritance2.rs
+++ b/src/test/run-pass/trait-inheritance2.rs
@@ -31,4 +31,3 @@ pub fn main() {
     let a = &A { x: 3 };
     f(a);
 }
-
diff --git a/src/test/run-pass/trait-region-pointer-simple.rs b/src/test/run-pass/trait-region-pointer-simple.rs
index 285b0e65daf..a2742828a1b 100644
--- a/src/test/run-pass/trait-region-pointer-simple.rs
+++ b/src/test/run-pass/trait-region-pointer-simple.rs
@@ -28,4 +28,3 @@ pub fn main() {
     let b = (&a) as &Foo;
     assert!(b.f() == 3);
 }
-
diff --git a/src/test/run-pass/trait-static-method-overwriting.rs b/src/test/run-pass/trait-static-method-overwriting.rs
index a8a579422a3..86ebc5356eb 100644
--- a/src/test/run-pass/trait-static-method-overwriting.rs
+++ b/src/test/run-pass/trait-static-method-overwriting.rs
@@ -21,7 +21,7 @@ mod base {
 
     impl ::base::HasNew<Foo> for Foo {
         fn new() -> Foo {
-			unsafe { io::println("Foo"); }
+            unsafe { io::println("Foo"); }
             Foo { dummy: () }
         }
     }
@@ -32,7 +32,7 @@ mod base {
 
     impl ::base::HasNew<Bar> for Bar {
         fn new() -> Bar {
-			unsafe { io::println("Bar"); }
+            unsafe { io::println("Bar"); }
             Bar { dummy: () }
         }
     }
@@ -40,5 +40,5 @@ mod base {
 
 pub fn main() {
     let f: base::Foo = base::HasNew::new::<base::Foo, base::Foo>();
-	let b: base::Bar = base::HasNew::new::<base::Bar, base::Bar>();
+    let b: base::Bar = base::HasNew::new::<base::Bar, base::Bar>();
 }
diff --git a/src/test/run-pass/traits.rs b/src/test/run-pass/traits.rs
index c4ec15ff273..ba3e8e082b3 100644
--- a/src/test/run-pass/traits.rs
+++ b/src/test/run-pass/traits.rs
@@ -53,4 +53,3 @@ impl Ord for int {
         self == (*a)
     }
 }
-
diff --git a/src/test/run-pass/tuple-struct-construct.rs b/src/test/run-pass/tuple-struct-construct.rs
index ea410093c4b..c5ea3e14d39 100644
--- a/src/test/run-pass/tuple-struct-construct.rs
+++ b/src/test/run-pass/tuple-struct-construct.rs
@@ -14,4 +14,3 @@ pub fn main() {
     let x = Foo(1, 2);
     io::println(fmt!("%?", x));
 }
-
diff --git a/src/test/run-pass/tuple-struct-destructuring.rs b/src/test/run-pass/tuple-struct-destructuring.rs
index 7e6b9570def..1cb944da040 100644
--- a/src/test/run-pass/tuple-struct-destructuring.rs
+++ b/src/test/run-pass/tuple-struct-destructuring.rs
@@ -17,4 +17,3 @@ pub fn main() {
     assert!(y == 1);
     assert!(z == 2);
 }
-
diff --git a/src/test/run-pass/tuple-struct-matching.rs b/src/test/run-pass/tuple-struct-matching.rs
index 405616f9b1f..e3cbd1201c1 100644
--- a/src/test/run-pass/tuple-struct-matching.rs
+++ b/src/test/run-pass/tuple-struct-matching.rs
@@ -20,4 +20,3 @@ pub fn main() {
         }
     }
 }
-
diff --git a/src/test/run-pass/tuple-struct-trivial.rs b/src/test/run-pass/tuple-struct-trivial.rs
index 8ddc04a186f..c6c32cf49c6 100644
--- a/src/test/run-pass/tuple-struct-trivial.rs
+++ b/src/test/run-pass/tuple-struct-trivial.rs
@@ -14,4 +14,3 @@ struct Foo(int, int, int);
 
 pub fn main() {
 }
-
diff --git a/src/test/run-pass/type-sizes.rs b/src/test/run-pass/type-sizes.rs
index bc2ca20d642..134f1e4098f 100644
--- a/src/test/run-pass/type-sizes.rs
+++ b/src/test/run-pass/type-sizes.rs
@@ -8,9 +8,16 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// xfail-test
-use sys::rustrt::size_of;
-extern mod std;
+extern mod core;
+use core::sys::size_of;
+
+struct t {a: u8, b: i8}
+struct u {a: u8, b: i8, c: u8}
+struct v {a: u8, b: i8, c: v2, d: u32}
+struct v2 {u: char, v: u8}
+struct w {a: int, b: ()}
+struct x {a: int, b: (), c: ()}
+struct y {x: int}
 
 pub fn main() {
     assert!((size_of::<u8>() == 1 as uint));
@@ -18,14 +25,14 @@ pub fn main() {
     assert!((size_of::<char>() == 4 as uint));
     assert!((size_of::<i8>() == 1 as uint));
     assert!((size_of::<i32>() == 4 as uint));
-    assert!((size_of::<{a: u8, b: i8}>() == 2 as uint));
-    assert!((size_of::<{a: u8, b: i8, c: u8}>() == 3 as uint));
+    assert!((size_of::<t>() == 2 as uint));
+    assert!((size_of::<u>() == 3 as uint));
     // Alignment causes padding before the char and the u32.
 
-    assert!(size_of::<{a: u8, b: i8, c: {u: char, v: u8}, d: u32}>() ==
+    assert!(size_of::<v>() ==
                 16 as uint);
     assert!((size_of::<int>() == size_of::<uint>()));
-    assert!((size_of::<{a: int, b: ()}>() == size_of::<int>()));
-    assert!((size_of::<{a: int, b: (), c: ()}>() == size_of::<int>()));
-    assert!((size_of::<int>() == size_of::<{x: int}>()));
+    assert!((size_of::<w>() == size_of::<int>()));
+    assert!((size_of::<x>() == size_of::<int>()));
+    assert!((size_of::<int>() == size_of::<y>()));
 }
diff --git a/src/test/run-pass/typeclasses-eq-example-static.rs b/src/test/run-pass/typeclasses-eq-example-static.rs
index 9c5f8c3218a..c14dd0471f9 100644
--- a/src/test/run-pass/typeclasses-eq-example-static.rs
+++ b/src/test/run-pass/typeclasses-eq-example-static.rs
@@ -38,7 +38,7 @@ impl Equal for ColorTree {
     fn isEq(a: ColorTree, b: ColorTree) -> bool {
         match (a, b) {
           (leaf(x), leaf(y)) => { Equal::isEq(x, y) }
-          (branch(l1, r1), branch(l2, r2)) => { 
+          (branch(l1, r1), branch(l2, r2)) => {
             Equal::isEq(*l1, *l2) && Equal::isEq(*r1, *r2)
           }
           _ => { false }
diff --git a/src/test/run-pass/typeclasses-eq-example.rs b/src/test/run-pass/typeclasses-eq-example.rs
index 51c19cef50a..18a68bc1c34 100644
--- a/src/test/run-pass/typeclasses-eq-example.rs
+++ b/src/test/run-pass/typeclasses-eq-example.rs
@@ -37,7 +37,7 @@ impl Equal for ColorTree {
     fn isEq(&self, a: ColorTree) -> bool {
         match (*self, a) {
           (leaf(x), leaf(y)) => { x.isEq(y) }
-          (branch(l1, r1), branch(l2, r2)) => { 
+          (branch(l1, r1), branch(l2, r2)) => {
             (*l1).isEq(*l2) && (*r1).isEq(*r2)
           }
           _ => { false }
diff --git a/src/test/run-pass/unique-object.rs b/src/test/run-pass/unique-object.rs
index 1cf4cf09b81..5e0954969ef 100644
--- a/src/test/run-pass/unique-object.rs
+++ b/src/test/run-pass/unique-object.rs
@@ -27,4 +27,3 @@ pub fn main() {
     let y = x as ~Foo;
     assert!(y.f() == 10);
 }
-
diff --git a/src/test/run-pass/unit-like-struct.rs b/src/test/run-pass/unit-like-struct.rs
index 837bfa50b8e..1b81015b029 100644
--- a/src/test/run-pass/unit-like-struct.rs
+++ b/src/test/run-pass/unit-like-struct.rs
@@ -16,4 +16,3 @@ pub fn main() {
         Foo => { io::println("hi"); }
     }
 }
-
diff --git a/src/test/run-pass/unsafe-pointer-assignability.rs b/src/test/run-pass/unsafe-pointer-assignability.rs
index 05c9cd8a574..f19558fbb1d 100644
--- a/src/test/run-pass/unsafe-pointer-assignability.rs
+++ b/src/test/run-pass/unsafe-pointer-assignability.rs
@@ -17,6 +17,3 @@ fn f(x: *int) {
 pub fn main() {
     f(&3);
 }
-
-
-
diff --git a/src/test/run-pass/vec-fixed-length.rs b/src/test/run-pass/vec-fixed-length.rs
index 5ce1b04dbe9..2c4add63e8b 100644
--- a/src/test/run-pass/vec-fixed-length.rs
+++ b/src/test/run-pass/vec-fixed-length.rs
@@ -12,4 +12,3 @@ pub fn main() {
     let x: [int, ..4] = [1, 2, 3, 4];
     io::println(fmt!("%d", x[0]));
 }
-