about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2017-07-17 09:32:08 -0700
committerAlex Crichton <alex@alexcrichton.com>2017-07-25 07:03:19 -0700
commit9010567dcc0aba772525841aee67c030ea3450c6 (patch)
tree26b11fb6639fcde4477f8f0db8f04af1b5984a7c /src
parent7c46c6c59dbee8d6385f8924fe27cc5a7893841f (diff)
downloadrust-9010567dcc0aba772525841aee67c030ea3450c6.tar.gz
rust-9010567dcc0aba772525841aee67c030ea3450c6.zip
Bump master to 1.21.0
This commit bumps the master branch's version to 1.21.0 and also updates the
bootstrap compiler from the freshly minted beta release.
Diffstat (limited to 'src')
-rw-r--r--src/Cargo.lock141
-rw-r--r--src/Cargo.toml2
-rw-r--r--src/bootstrap/channel.rs2
-rw-r--r--src/bootstrap/check.rs68
-rw-r--r--src/bootstrap/compile.rs237
-rw-r--r--src/bootstrap/doc.rs11
-rw-r--r--src/bootstrap/tool.rs2
-rw-r--r--src/liballoc/lib.rs3
-rw-r--r--src/liballoc_jemalloc/Cargo.toml6
-rw-r--r--src/liballoc_jemalloc/lib.rs17
-rw-r--r--src/liballoc_system/Cargo.toml4
-rw-r--r--src/liballoc_system/lib.rs149
-rw-r--r--src/liballoc_system/old.rs268
-rw-r--r--src/libcore/intrinsics.rs2
-rw-r--r--src/libcore/lib.rs2
-rw-r--r--src/libcore/num/mod.rs21
-rw-r--r--src/libcore/panicking.rs25
-rw-r--r--src/libprofiler_builtins/lib.rs4
-rw-r--r--src/librustc/lib.rs2
-rw-r--r--src/librustc_asan/lib.rs8
-rw-r--r--src/librustc_bitflags/lib.rs2
-rw-r--r--src/librustc_borrowck/lib.rs2
-rw-r--r--src/librustc_data_structures/lib.rs3
-rw-r--r--src/librustc_llvm/lib.rs2
-rw-r--r--src/librustc_lsan/lib.rs6
-rw-r--r--src/librustc_mir/lib.rs2
-rw-r--r--src/librustc_msan/lib.rs6
-rw-r--r--src/librustc_resolve/lib.rs2
-rw-r--r--src/librustc_trans/lib.rs2
-rw-r--r--src/libstd/heap.rs3
-rw-r--r--src/libstd/lib.rs3
-rw-r--r--src/libstd/thread/local.rs67
-rw-r--r--src/stage0.txt2
m---------src/tools/cargo0
34 files changed, 315 insertions, 761 deletions
diff --git a/src/Cargo.lock b/src/Cargo.lock
index fba32d4e40a..9ee9bdfd775 100644
--- a/src/Cargo.lock
+++ b/src/Cargo.lock
@@ -75,7 +75,7 @@ version = "0.2.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)",
  "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
@@ -88,7 +88,7 @@ dependencies = [
  "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "dbghelp-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc-demangle 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
@@ -99,7 +99,7 @@ version = "0.1.12"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "gcc 0.3.51 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -135,7 +135,7 @@ dependencies = [
  "gcc 0.3.51 (registry+https://github.com/rust-lang/crates.io-index)",
  "getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
  "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)",
  "num_cpus 1.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde_derive 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -170,59 +170,19 @@ dependencies = [
 
 [[package]]
 name = "cargo"
-version = "0.21.0"
-dependencies = [
- "advapi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "atty 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "bufstream 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "cargotest 0.1.0",
- "crates-io 0.10.0",
- "crossbeam 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
- "curl 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "docopt 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "error-chain 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
- "flate2 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
- "fs2 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "git2 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
- "git2-curl 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
- "hamcrest 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "hex 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "ignore 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "jobserver 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
- "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
- "libgit2-sys 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
- "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "num_cpus 1.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "openssl 0.9.15 (registry+https://github.com/rust-lang/crates.io-index)",
- "psapi-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "scoped-tls 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "semver 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde_derive 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde_ignored 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "shell-escape 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "tar 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)",
- "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
- "termcolor 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "toml 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
-]
+version = "0.22.0"
+source = "git+https://github.com/rust-lang/cargo#88aa6423a164774d09abc78a24e74e8e665f651b"
+replace = "cargo 0.22.0"
 
 [[package]]
 name = "cargo"
 version = "0.22.0"
-source = "git+https://github.com/rust-lang/cargo#47783c151dcfcd3b835cd2012bfc2810c0f8d017"
 dependencies = [
  "advapi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "atty 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "crates-io 0.11.0 (git+https://github.com/rust-lang/cargo)",
+ "bufstream 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cargotest 0.1.0",
+ "crates-io 0.11.0",
  "crossbeam 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
  "curl 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "docopt 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -234,12 +194,13 @@ dependencies = [
  "git2 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "git2-curl 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
+ "hamcrest 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "hex 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "home 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "ignore 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "jobserver 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)",
  "libgit2-sys 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -266,14 +227,14 @@ name = "cargotest"
 version = "0.1.0"
 dependencies = [
  "bufstream 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "cargo 0.21.0",
+ "cargo 0.22.0",
  "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
  "flate2 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
  "git2 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "hamcrest 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "hex 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -341,7 +302,7 @@ dependencies = [
  "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
  "getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
@@ -359,20 +320,7 @@ dependencies = [
 
 [[package]]
 name = "crates-io"
-version = "0.10.0"
-dependencies = [
- "curl 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "error-chain 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde_derive 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
-name = "crates-io"
 version = "0.11.0"
-source = "git+https://github.com/rust-lang/cargo#47783c151dcfcd3b835cd2012bfc2810c0f8d017"
 dependencies = [
  "curl 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "error-chain 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -393,7 +341,7 @@ version = "0.4.8"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "curl-sys 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)",
  "openssl-probe 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "openssl-sys 0.9.15 (registry+https://github.com/rust-lang/crates.io-index)",
  "socket2 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -406,7 +354,7 @@ version = "0.3.14"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "gcc 0.3.51 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)",
  "libz-sys 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)",
  "openssl-sys 0.9.15 (registry+https://github.com/rust-lang/crates.io-index)",
  "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -497,7 +445,7 @@ name = "filetime"
 version = "0.1.10"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -513,7 +461,7 @@ name = "flate2"
 version = "0.2.19"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)",
  "miniz-sys 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
@@ -537,7 +485,7 @@ version = "0.4.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)",
  "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
@@ -562,7 +510,7 @@ version = "0.6.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)",
  "libgit2-sys 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
  "openssl-probe 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "openssl-sys 0.9.15 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -703,7 +651,7 @@ name = "jobserver"
 version = "0.1.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)",
  "rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
@@ -755,7 +703,7 @@ dependencies = [
 
 [[package]]
 name = "libc"
-version = "0.2.26"
+version = "0.2.27"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
@@ -766,7 +714,7 @@ dependencies = [
  "cmake 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)",
  "curl-sys 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
  "gcc 0.3.51 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)",
  "libssh2-sys 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "libz-sys 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)",
  "openssl-sys 0.9.15 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -779,7 +727,7 @@ version = "0.2.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "cmake 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)",
  "libz-sys 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)",
  "openssl-sys 0.9.15 (registry+https://github.com/rust-lang/crates.io-index)",
  "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -791,7 +739,7 @@ version = "1.0.16"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "gcc 0.3.51 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)",
  "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
  "vcpkg 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
@@ -812,7 +760,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
  "gcc 0.3.51 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -842,7 +790,7 @@ name = "memchr"
 version = "0.1.11"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -850,7 +798,7 @@ name = "memchr"
 version = "1.0.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -859,7 +807,7 @@ version = "0.1.9"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "gcc 0.3.51 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -884,7 +832,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)",
  "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
@@ -960,7 +908,7 @@ name = "num_cpus"
 version = "1.6.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -976,7 +924,7 @@ dependencies = [
  "bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "foreign-types 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)",
  "openssl-sys 0.9.15 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
@@ -991,7 +939,7 @@ version = "0.9.15"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "gcc 0.3.51 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)",
  "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
@@ -1113,7 +1061,7 @@ name = "rand"
 version = "0.3.15"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -1641,7 +1589,7 @@ dependencies = [
  "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
  "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1746,7 +1694,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)",
  "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
@@ -1865,7 +1813,7 @@ name = "syntex_errors"
 version = "0.52.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
  "syntex_pos 0.52.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1887,7 +1835,7 @@ version = "0.52.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
  "syntex_errors 0.52.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1902,7 +1850,7 @@ version = "0.4.13"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)",
  "xattr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
@@ -1933,7 +1881,7 @@ version = "0.3.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)",
  "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
@@ -1968,7 +1916,7 @@ version = "2.0.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -2157,7 +2105,7 @@ name = "xattr"
 version = "0.1.11"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -2189,7 +2137,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 "checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de"
 "checksum clap 2.25.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7f1aabf260a8f3fefa8871f16b531038c98dd9eab1cfa2c575e78c459abfa3a0"
 "checksum cmake 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)" = "b8ebbb35d3dc9cd09497168f33de1acb79b265d350ab0ac34133b98f8509af1f"
-"checksum crates-io 0.11.0 (git+https://github.com/rust-lang/cargo)" = "<none>"
 "checksum crossbeam 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "0c5ea215664ca264da8a9d9c3be80d2eaf30923c259d03e870388eb927508f97"
 "checksum curl 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7034c534a1d7d22f7971d6088aa9d281d219ef724026c3428092500f41ae9c2c"
 "checksum curl-sys 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d5481162dc4f424d088581db2f979fa7d4c238fe9794595de61d8d7522e277de"
@@ -2226,7 +2173,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
 "checksum languageserver-types 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d52e477b23bf52cd3ca0f9fc6c5d14be954eec97e3b9cdfbd962d911bd533caf"
 "checksum lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3b37545ab726dd833ec6420aaba8231c5b320814b9029ad585555d2a03e94fbf"
-"checksum libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)" = "30885bcb161cf67054244d10d4a7f4835ffd58773bc72e07d35fecf472295503"
+"checksum libc 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)" = "719aa0af4c241fa71d396ffdfe584aa758f08f35b4680ec3f03ecc2c3fe69b76"
 "checksum libgit2-sys 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "df18a822100352d9863b302faf6f8f25c0e77f0e60feb40e5dbe1238b7f13b1d"
 "checksum libssh2-sys 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0db4ec23611747ef772db1c4d650f8bd762f07b461727ec998f953c614024b75"
 "checksum libz-sys 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)" = "3fdd64ef8ee652185674455c1d450b83cbc8ad895625d543b5324d923f82e4d8"
diff --git a/src/Cargo.toml b/src/Cargo.toml
index f027965e791..6e81ec67260 100644
--- a/src/Cargo.toml
+++ b/src/Cargo.toml
@@ -51,4 +51,4 @@ debug = false
 debug-assertions = false
 
 [replace]
-"https://github.com/rust-lang/cargo#0.21.0" = { path = "tools/cargo" }
+"https://github.com/rust-lang/cargo#0.22.0" = { path = "tools/cargo" }
diff --git a/src/bootstrap/channel.rs b/src/bootstrap/channel.rs
index 1153acfa57d..beefaeab90b 100644
--- a/src/bootstrap/channel.rs
+++ b/src/bootstrap/channel.rs
@@ -23,7 +23,7 @@ use build_helper::output;
 use Build;
 
 // The version number
-pub const CFG_RELEASE_NUM: &str = "1.20.0";
+pub const CFG_RELEASE_NUM: &str = "1.21.0";
 
 // An optional number to put after the label, e.g. '.2' -> '-beta.2'
 // Be sure to make this starts with a dot to conform to semver pre-release
diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs
index 472bfafc20a..d2e181f94c6 100644
--- a/src/bootstrap/check.rs
+++ b/src/bootstrap/check.rs
@@ -25,15 +25,14 @@ use std::io::Read;
 
 use build_helper::{self, output};
 
-use {Build, Mode};
-use dist;
-use util::{self, dylib_path, dylib_path_var};
-
+use builder::{Kind, RunConfig, ShouldRun, Builder, Compiler, Step};
+use cache::{INTERNER, Interned};
 use compile;
+use dist;
 use native;
-use builder::{Kind, RunConfig, ShouldRun, Builder, Compiler, Step};
 use tool::{self, Tool};
-use cache::{INTERNER, Interned};
+use util::{self, dylib_path, dylib_path_var};
+use {Build, Mode};
 
 const ADB_TEST_DIR: &str = "/data/tmp/work";
 
@@ -963,16 +962,31 @@ impl Step for Crate {
 
         builder.ensure(compile::Test { compiler, target });
         builder.ensure(RemoteCopyLibs { compiler, target });
-        let (name, path, features, root) = match mode {
+
+        // If we're not doing a full bootstrap but we're testing a stage2 version of
+        // libstd, then what we're actually testing is the libstd produced in
+        // stage1. Reflect that here by updating the compiler that we're working
+        // with automatically.
+        let compiler = if build.force_use_stage1(compiler, target) {
+            builder.compiler(1, compiler.host)
+        } else {
+            compiler.clone()
+        };
+
+        let mut cargo = builder.cargo(compiler, mode, target, test_kind.subcommand());
+        let (name, root) = match mode {
             Mode::Libstd => {
-                ("libstd", "src/libstd", build.std_features(), "std")
+                compile::std_cargo(build, &compiler, target, &mut cargo);
+                ("libstd", "std")
             }
             Mode::Libtest => {
-                ("libtest", "src/libtest", String::new(), "test")
+                compile::test_cargo(build, &compiler, target, &mut cargo);
+                ("libtest", "test")
             }
             Mode::Librustc => {
                 builder.ensure(compile::Rustc { compiler, target });
-                ("librustc", "src/rustc", build.rustc_features(), "rustc-main")
+                compile::rustc_cargo(build, &compiler, target, &mut cargo);
+                ("librustc", "rustc-main")
             }
             _ => panic!("can only test libraries"),
         };
@@ -983,25 +997,11 @@ impl Step for Crate {
         println!("{} {} stage{} ({} -> {})", test_kind, name, compiler.stage,
                 &compiler.host, target);
 
-        // If we're not doing a full bootstrap but we're testing a stage2 version of
-        // libstd, then what we're actually testing is the libstd produced in
-        // stage1. Reflect that here by updating the compiler that we're working
-        // with automatically.
-        let compiler = if build.force_use_stage1(compiler, target) {
-            builder.compiler(1, compiler.host)
-        } else {
-            compiler.clone()
-        };
-
         // Build up the base `cargo test` command.
         //
         // Pass in some standard flags then iterate over the graph we've discovered
         // in `cargo metadata` with the maps above and figure out what `-p`
         // arguments need to get passed.
-        let mut cargo = builder.cargo(compiler, mode, target, test_kind.subcommand());
-        cargo.arg("--manifest-path")
-            .arg(build.src.join(path).join("Cargo.toml"))
-            .arg("--features").arg(features);
         if test_kind.subcommand() == "test" && !build.fail_fast {
             cargo.arg("--no-fail-fast");
         }
@@ -1014,16 +1014,18 @@ impl Step for Crate {
                 let mut visited = HashSet::new();
                 let mut next = vec![root];
                 while let Some(name) = next.pop() {
-                    // Right now jemalloc is our only target-specific crate in the
-                    // sense that it's not present on all platforms. Custom skip it
-                    // here for now, but if we add more this probably wants to get
-                    // more generalized.
+                    // Right now jemalloc and the sanitizer crates are
+                    // target-specific crate in the sense that it's not present
+                    // on all platforms. Custom skip it here for now, but if we
+                    // add more this probably wants to get more generalized.
                     //
-                    // Also skip `build_helper` as it's not compiled normally for
-                    // target during the bootstrap and it's just meant to be a
-                    // helper crate, not tested. If it leaks through then it ends up
-                    // messing with various mtime calculations and such.
-                    if !name.contains("jemalloc") && *name != *"build_helper" {
+                    // Also skip `build_helper` as it's not compiled normally
+                    // for target during the bootstrap and it's just meant to be
+                    // a helper crate, not tested. If it leaks through then it
+                    // ends up messing with various mtime calculations and such.
+                    if !name.contains("jemalloc") &&
+                       *name != *"build_helper" &&
+                       !(name.starts_with("rustc_") && name.ends_with("san")) {
                         cargo.arg("-p").arg(&format!("{}:0.0.0", name));
                     }
                     for dep in build.crates[&name].deps.iter() {
diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs
index cbe2be2d26a..2e808c65684 100644
--- a/src/bootstrap/compile.rs
+++ b/src/bootstrap/compile.rs
@@ -91,47 +91,7 @@ impl Step for Std {
         let out_dir = build.cargo_out(compiler, Mode::Libstd, target);
         build.clear_if_dirty(&out_dir, &builder.rustc(compiler));
         let mut cargo = builder.cargo(compiler, Mode::Libstd, target, "build");
-        let mut features = build.std_features();
-
-        if let Some(target) = env::var_os("MACOSX_STD_DEPLOYMENT_TARGET") {
-            cargo.env("MACOSX_DEPLOYMENT_TARGET", target);
-        }
-
-        // When doing a local rebuild we tell cargo that we're stage1 rather than
-        // stage0. This works fine if the local rust and being-built rust have the
-        // same view of what the default allocator is, but fails otherwise. Since
-        // we don't have a way to express an allocator preference yet, work
-        // around the issue in the case of a local rebuild with jemalloc disabled.
-        if compiler.stage == 0 && build.local_rebuild && !build.config.use_jemalloc {
-            features.push_str(" force_alloc_system");
-        }
-
-        if compiler.stage != 0 && build.config.sanitizers {
-            // This variable is used by the sanitizer runtime crates, e.g.
-            // rustc_lsan, to build the sanitizer runtime from C code
-            // When this variable is missing, those crates won't compile the C code,
-            // so we don't set this variable during stage0 where llvm-config is
-            // missing
-            // We also only build the runtimes when --enable-sanitizers (or its
-            // config.toml equivalent) is used
-            cargo.env("LLVM_CONFIG", build.llvm_config(target));
-        }
-
-        cargo.arg("--features").arg(features)
-            .arg("--manifest-path")
-            .arg(build.src.join("src/libstd/Cargo.toml"));
-
-        if let Some(target) = build.config.target_config.get(&target) {
-            if let Some(ref jemalloc) = target.jemalloc {
-                cargo.env("JEMALLOC_OVERRIDE", jemalloc);
-            }
-        }
-        if target.contains("musl") {
-            if let Some(p) = build.musl_root(target) {
-                cargo.env("MUSL_ROOT", p);
-            }
-        }
-
+        std_cargo(build, &compiler, target, &mut cargo);
         run_cargo(build,
                 &mut cargo,
                 &libstd_stamp(build, compiler, target));
@@ -144,6 +104,53 @@ impl Step for Std {
     }
 }
 
+/// Configure cargo to compile the standard library, adding appropriate env vars
+/// and such.
+pub fn std_cargo(build: &Build,
+                 compiler: &Compiler,
+                 target: Interned<String>,
+                 cargo: &mut Command) {
+    let mut features = build.std_features();
+
+    if let Some(target) = env::var_os("MACOSX_STD_DEPLOYMENT_TARGET") {
+        cargo.env("MACOSX_DEPLOYMENT_TARGET", target);
+    }
+
+    // When doing a local rebuild we tell cargo that we're stage1 rather than
+    // stage0. This works fine if the local rust and being-built rust have the
+    // same view of what the default allocator is, but fails otherwise. Since
+    // we don't have a way to express an allocator preference yet, work
+    // around the issue in the case of a local rebuild with jemalloc disabled.
+    if compiler.stage == 0 && build.local_rebuild && !build.config.use_jemalloc {
+        features.push_str(" force_alloc_system");
+    }
+
+    if compiler.stage != 0 && build.config.sanitizers {
+        // This variable is used by the sanitizer runtime crates, e.g.
+        // rustc_lsan, to build the sanitizer runtime from C code
+        // When this variable is missing, those crates won't compile the C code,
+        // so we don't set this variable during stage0 where llvm-config is
+        // missing
+        // We also only build the runtimes when --enable-sanitizers (or its
+        // config.toml equivalent) is used
+        cargo.env("LLVM_CONFIG", build.llvm_config(target));
+    }
+
+    cargo.arg("--features").arg(features)
+        .arg("--manifest-path")
+        .arg(build.src.join("src/libstd/Cargo.toml"));
+
+    if let Some(target) = build.config.target_config.get(&target) {
+        if let Some(ref jemalloc) = target.jemalloc {
+            cargo.env("JEMALLOC_OVERRIDE", jemalloc);
+        }
+    }
+    if target.contains("musl") {
+        if let Some(p) = build.musl_root(target) {
+            cargo.env("MUSL_ROOT", p);
+        }
+    }
+}
 
 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
 struct StdLink {
@@ -329,11 +336,7 @@ impl Step for Test {
         let out_dir = build.cargo_out(compiler, Mode::Libtest, target);
         build.clear_if_dirty(&out_dir, &libstd_stamp(build, compiler, target));
         let mut cargo = builder.cargo(compiler, Mode::Libtest, target, "build");
-        if let Some(target) = env::var_os("MACOSX_STD_DEPLOYMENT_TARGET") {
-            cargo.env("MACOSX_DEPLOYMENT_TARGET", target);
-        }
-        cargo.arg("--manifest-path")
-            .arg(build.src.join("src/libtest/Cargo.toml"));
+        test_cargo(build, &compiler, target, &mut cargo);
         run_cargo(build,
                 &mut cargo,
                 &libtest_stamp(build, compiler, target));
@@ -346,6 +349,18 @@ impl Step for Test {
     }
 }
 
+/// Same as `std_cargo`, but for libtest
+pub fn test_cargo(build: &Build,
+                  _compiler: &Compiler,
+                  _target: Interned<String>,
+                  cargo: &mut Command) {
+    if let Some(target) = env::var_os("MACOSX_STD_DEPLOYMENT_TARGET") {
+        cargo.env("MACOSX_DEPLOYMENT_TARGET", target);
+    }
+    cargo.arg("--manifest-path")
+        .arg(build.src.join("src/libtest/Cargo.toml"));
+}
+
 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
 pub struct TestLink {
     pub compiler: Compiler,
@@ -443,67 +458,7 @@ impl Step for Rustc {
         build.clear_if_dirty(&out_dir, &libtest_stamp(build, compiler, target));
 
         let mut cargo = builder.cargo(compiler, Mode::Librustc, target, "build");
-        cargo.arg("--features").arg(build.rustc_features())
-             .arg("--manifest-path")
-             .arg(build.src.join("src/rustc/Cargo.toml"));
-
-        // Set some configuration variables picked up by build scripts and
-        // the compiler alike
-        cargo.env("CFG_RELEASE", build.rust_release())
-             .env("CFG_RELEASE_CHANNEL", &build.config.channel)
-             .env("CFG_VERSION", build.rust_version())
-             .env("CFG_PREFIX", build.config.prefix.clone().unwrap_or_default());
-
-        if compiler.stage == 0 {
-            cargo.env("CFG_LIBDIR_RELATIVE", "lib");
-        } else {
-            let libdir_relative =
-                build.config.libdir_relative.clone().unwrap_or(PathBuf::from("lib"));
-            cargo.env("CFG_LIBDIR_RELATIVE", libdir_relative);
-        }
-
-        // If we're not building a compiler with debugging information then remove
-        // these two env vars which would be set otherwise.
-        if build.config.rust_debuginfo_only_std {
-            cargo.env_remove("RUSTC_DEBUGINFO");
-            cargo.env_remove("RUSTC_DEBUGINFO_LINES");
-        }
-
-        if let Some(ref ver_date) = build.rust_info.commit_date() {
-            cargo.env("CFG_VER_DATE", ver_date);
-        }
-        if let Some(ref ver_hash) = build.rust_info.sha() {
-            cargo.env("CFG_VER_HASH", ver_hash);
-        }
-        if !build.unstable_features() {
-            cargo.env("CFG_DISABLE_UNSTABLE_FEATURES", "1");
-        }
-        // Flag that rust llvm is in use
-        if build.is_rust_llvm(target) {
-            cargo.env("LLVM_RUSTLLVM", "1");
-        }
-        cargo.env("LLVM_CONFIG", build.llvm_config(target));
-        let target_config = build.config.target_config.get(&target);
-        if let Some(s) = target_config.and_then(|c| c.llvm_config.as_ref()) {
-            cargo.env("CFG_LLVM_ROOT", s);
-        }
-        // Building with a static libstdc++ is only supported on linux right now,
-        // not for MSVC or macOS
-        if build.config.llvm_static_stdcpp &&
-           !target.contains("windows") &&
-           !target.contains("apple") {
-            cargo.env("LLVM_STATIC_STDCPP",
-                      compiler_file(build.cxx(target).unwrap(), "libstdc++.a"));
-        }
-        if build.config.llvm_link_shared {
-            cargo.env("LLVM_LINK_SHARED", "1");
-        }
-        if let Some(ref s) = build.config.rustc_default_linker {
-            cargo.env("CFG_DEFAULT_LINKER", s);
-        }
-        if let Some(ref s) = build.config.rustc_default_ar {
-            cargo.env("CFG_DEFAULT_AR", s);
-        }
+        rustc_cargo(build, &compiler, target, &mut cargo);
         run_cargo(build,
                   &mut cargo,
                   &librustc_stamp(build, compiler, target));
@@ -516,6 +471,74 @@ impl Step for Rustc {
     }
 }
 
+/// Same as `std_cargo`, but for libtest
+pub fn rustc_cargo(build: &Build,
+                   compiler: &Compiler,
+                   target: Interned<String>,
+                   cargo: &mut Command) {
+    cargo.arg("--features").arg(build.rustc_features())
+         .arg("--manifest-path")
+         .arg(build.src.join("src/rustc/Cargo.toml"));
+
+    // Set some configuration variables picked up by build scripts and
+    // the compiler alike
+    cargo.env("CFG_RELEASE", build.rust_release())
+         .env("CFG_RELEASE_CHANNEL", &build.config.channel)
+         .env("CFG_VERSION", build.rust_version())
+         .env("CFG_PREFIX", build.config.prefix.clone().unwrap_or_default());
+
+    if compiler.stage == 0 {
+        cargo.env("CFG_LIBDIR_RELATIVE", "lib");
+    } else {
+        let libdir_relative =
+            build.config.libdir_relative.clone().unwrap_or(PathBuf::from("lib"));
+        cargo.env("CFG_LIBDIR_RELATIVE", libdir_relative);
+    }
+
+    // If we're not building a compiler with debugging information then remove
+    // these two env vars which would be set otherwise.
+    if build.config.rust_debuginfo_only_std {
+        cargo.env_remove("RUSTC_DEBUGINFO");
+        cargo.env_remove("RUSTC_DEBUGINFO_LINES");
+    }
+
+    if let Some(ref ver_date) = build.rust_info.commit_date() {
+        cargo.env("CFG_VER_DATE", ver_date);
+    }
+    if let Some(ref ver_hash) = build.rust_info.sha() {
+        cargo.env("CFG_VER_HASH", ver_hash);
+    }
+    if !build.unstable_features() {
+        cargo.env("CFG_DISABLE_UNSTABLE_FEATURES", "1");
+    }
+    // Flag that rust llvm is in use
+    if build.is_rust_llvm(target) {
+        cargo.env("LLVM_RUSTLLVM", "1");
+    }
+    cargo.env("LLVM_CONFIG", build.llvm_config(target));
+    let target_config = build.config.target_config.get(&target);
+    if let Some(s) = target_config.and_then(|c| c.llvm_config.as_ref()) {
+        cargo.env("CFG_LLVM_ROOT", s);
+    }
+    // Building with a static libstdc++ is only supported on linux right now,
+    // not for MSVC or macOS
+    if build.config.llvm_static_stdcpp &&
+       !target.contains("windows") &&
+       !target.contains("apple") {
+        cargo.env("LLVM_STATIC_STDCPP",
+                  compiler_file(build.cxx(target).unwrap(), "libstdc++.a"));
+    }
+    if build.config.llvm_link_shared {
+        cargo.env("LLVM_LINK_SHARED", "1");
+    }
+    if let Some(ref s) = build.config.rustc_default_linker {
+        cargo.env("CFG_DEFAULT_LINKER", s);
+    }
+    if let Some(ref s) = build.config.rustc_default_ar {
+        cargo.env("CFG_DEFAULT_AR", s);
+    }
+}
+
 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
 struct RustcLink {
     pub compiler: Compiler,
diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs
index 8834fa24d69..249ed2a2223 100644
--- a/src/bootstrap/doc.rs
+++ b/src/bootstrap/doc.rs
@@ -442,9 +442,7 @@ impl Step for Std {
         t!(symlink_dir_force(&my_out, &out_dir));
 
         let mut cargo = builder.cargo(compiler, Mode::Libstd, target, "doc");
-        cargo.arg("--manifest-path")
-             .arg(build.src.join("src/libstd/Cargo.toml"))
-             .arg("--features").arg(build.std_features());
+        compile::std_cargo(build, &compiler, target, &mut cargo);
 
         // We don't want to build docs for internal std dependencies unless
         // in compiler-docs mode. When not in that mode, we whitelist the crates
@@ -520,8 +518,7 @@ impl Step for Test {
         t!(symlink_dir_force(&my_out, &out_dir));
 
         let mut cargo = builder.cargo(compiler, Mode::Libtest, target, "doc");
-        cargo.arg("--manifest-path")
-             .arg(build.src.join("src/libtest/Cargo.toml"));
+        compile::test_cargo(build, &compiler, target, &mut cargo);
         build.run(&mut cargo);
         cp_r(&my_out, &out);
     }
@@ -582,9 +579,7 @@ impl Step for Rustc {
         t!(symlink_dir_force(&my_out, &out_dir));
 
         let mut cargo = builder.cargo(compiler, Mode::Librustc, target, "doc");
-        cargo.arg("--manifest-path")
-             .arg(build.src.join("src/rustc/Cargo.toml"))
-             .arg("--features").arg(build.rustc_features());
+        compile::rustc_cargo(build, &compiler, target, &mut cargo);
 
         if build.config.compiler_docs {
             // src/rustc/Cargo.toml contains bin crates called rustc and rustdoc
diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs
index b31d891051c..f32cddbafc3 100644
--- a/src/bootstrap/tool.rs
+++ b/src/bootstrap/tool.rs
@@ -263,7 +263,7 @@ impl Step for Cargo {
             stage: self.stage,
             target: self.target,
             tool: "cargo",
-            mode: Mode::Libstd,
+            mode: Mode::Librustc,
         })
     }
 }
diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs
index 80532bbdda1..91653f87a30 100644
--- a/src/liballoc/lib.rs
+++ b/src/liballoc/lib.rs
@@ -85,7 +85,6 @@
 #![cfg_attr(not(test), feature(slice_rotate))]
 #![cfg_attr(not(test), feature(str_checked_slicing))]
 #![cfg_attr(test, feature(rand, test))]
-#![cfg_attr(stage0, feature(allocator))]
 #![feature(allow_internal_unstable)]
 #![feature(box_patterns)]
 #![feature(box_syntax)]
@@ -124,7 +123,7 @@
 #![feature(unicode)]
 #![feature(unique)]
 #![feature(unsize)]
-#![cfg_attr(not(stage0), feature(allocator_internals))]
+#![feature(allocator_internals)]
 
 #![cfg_attr(not(test), feature(fused, fn_traits, placement_new_protocol))]
 #![cfg_attr(test, feature(test, box_heap))]
diff --git a/src/liballoc_jemalloc/Cargo.toml b/src/liballoc_jemalloc/Cargo.toml
index 99c0bf2aaab..94700cf4475 100644
--- a/src/liballoc_jemalloc/Cargo.toml
+++ b/src/liballoc_jemalloc/Cargo.toml
@@ -12,12 +12,10 @@ test = false
 doc = false
 
 [dependencies]
-core = { path = "../libcore" }
-libc = { path = "../rustc/libc_shim" }
-
-[target.'cfg(not(stage0))'.dependencies]
 alloc = { path = "../liballoc" }
 alloc_system = { path = "../liballoc_system" }
+core = { path = "../libcore" }
+libc = { path = "../rustc/libc_shim" }
 
 [build-dependencies]
 build_helper = { path = "../build_helper" }
diff --git a/src/liballoc_jemalloc/lib.rs b/src/liballoc_jemalloc/lib.rs
index 72686ddcc09..3a9cc1dd5a6 100644
--- a/src/liballoc_jemalloc/lib.rs
+++ b/src/liballoc_jemalloc/lib.rs
@@ -16,26 +16,21 @@
                       form or name",
             issue = "27783")]
 #![deny(warnings)]
+#![feature(alloc)]
+#![feature(alloc_system)]
 #![feature(libc)]
-#![feature(staged_api)]
 #![feature(linkage)]
-#![cfg_attr(stage0, allocator)]
-#![cfg_attr(stage0, feature(allocator))]
-#![cfg_attr(not(stage0), feature(global_allocator))]
-#![cfg_attr(all(not(stage0), not(dummy_jemalloc)), feature(allocator_api))]
-#![cfg_attr(not(stage0), feature(alloc))]
-#![cfg_attr(not(stage0), feature(alloc_system))]
+#![feature(staged_api)]
 #![cfg_attr(dummy_jemalloc, allow(dead_code))]
+#![cfg_attr(not(dummy_jemalloc), feature(allocator_api))]
 
-#[cfg(not(stage0))]
 extern crate alloc;
-#[cfg(not(stage0))]
 extern crate alloc_system;
 extern crate libc;
 
-#[cfg(all(not(stage0), not(dummy_jemalloc)))]
+#[cfg(not(dummy_jemalloc))]
 pub use contents::*;
-#[cfg(all(not(stage0), not(dummy_jemalloc)))]
+#[cfg(not(dummy_jemalloc))]
 mod contents {
     use core::ptr;
 
diff --git a/src/liballoc_system/Cargo.toml b/src/liballoc_system/Cargo.toml
index f20be5fdf5f..a725a8608be 100644
--- a/src/liballoc_system/Cargo.toml
+++ b/src/liballoc_system/Cargo.toml
@@ -10,8 +10,6 @@ test = false
 doc = false
 
 [dependencies]
+alloc = { path = "../liballoc" }
 core = { path = "../libcore" }
 libc = { path = "../rustc/libc_shim" }
-
-[target.'cfg(not(stage0))'.dependencies]
-alloc = { path = "../liballoc" }
diff --git a/src/liballoc_system/lib.rs b/src/liballoc_system/lib.rs
index afecfc16f2c..9a7cba21e3c 100644
--- a/src/liballoc_system/lib.rs
+++ b/src/liballoc_system/lib.rs
@@ -16,13 +16,10 @@
             reason = "this library is unlikely to be stabilized in its current \
                       form or name",
             issue = "27783")]
-#![cfg_attr(stage0, allocator)]
-#![cfg_attr(stage0, feature(allocator))]
-#![cfg_attr(stage0, feature(core_intrinsics))]
-#![cfg_attr(not(stage0), feature(global_allocator))]
-#![cfg_attr(not(stage0), feature(allocator_api))]
-#![cfg_attr(not(stage0), feature(alloc))]
-#![cfg_attr(not(stage0), feature(core_intrinsics))]
+#![feature(global_allocator)]
+#![feature(allocator_api)]
+#![feature(alloc)]
+#![feature(core_intrinsics)]
 #![feature(staged_api)]
 #![cfg_attr(any(unix, target_os = "redox"), feature(libc))]
 
@@ -44,90 +41,80 @@ const MIN_ALIGN: usize = 8;
               target_arch = "sparc64")))]
 const MIN_ALIGN: usize = 16;
 
-#[cfg(stage0)]
-pub use old::*;
-#[cfg(stage0)]
-mod old;
+extern crate alloc;
 
-#[cfg(not(stage0))]
-pub use new::System;
-#[cfg(not(stage0))]
-mod new {
-    pub extern crate alloc;
+use self::alloc::heap::{Alloc, AllocErr, Layout, Excess, CannotReallocInPlace};
 
-    use self::alloc::heap::{Alloc, AllocErr, Layout, Excess, CannotReallocInPlace};
+#[unstable(feature = "allocator_api", issue = "32838")]
+pub struct System;
 
-    #[unstable(feature = "allocator_api", issue = "32838")]
-    pub struct System;
-
-    #[unstable(feature = "allocator_api", issue = "32838")]
-    unsafe impl Alloc for System {
-        #[inline]
-        unsafe fn alloc(&mut self, layout: Layout) -> Result<*mut u8, AllocErr> {
-            (&*self).alloc(layout)
-        }
+#[unstable(feature = "allocator_api", issue = "32838")]
+unsafe impl Alloc for System {
+    #[inline]
+    unsafe fn alloc(&mut self, layout: Layout) -> Result<*mut u8, AllocErr> {
+        (&*self).alloc(layout)
+    }
 
-        #[inline]
-        unsafe fn alloc_zeroed(&mut self, layout: Layout)
-            -> Result<*mut u8, AllocErr>
-        {
-            (&*self).alloc_zeroed(layout)
-        }
+    #[inline]
+    unsafe fn alloc_zeroed(&mut self, layout: Layout)
+        -> Result<*mut u8, AllocErr>
+    {
+        (&*self).alloc_zeroed(layout)
+    }
 
-        #[inline]
-        unsafe fn dealloc(&mut self, ptr: *mut u8, layout: Layout) {
-            (&*self).dealloc(ptr, layout)
-        }
+    #[inline]
+    unsafe fn dealloc(&mut self, ptr: *mut u8, layout: Layout) {
+        (&*self).dealloc(ptr, layout)
+    }
 
-        #[inline]
-        unsafe fn realloc(&mut self,
-                          ptr: *mut u8,
-                          old_layout: Layout,
-                          new_layout: Layout) -> Result<*mut u8, AllocErr> {
-            (&*self).realloc(ptr, old_layout, new_layout)
-        }
+    #[inline]
+    unsafe fn realloc(&mut self,
+                      ptr: *mut u8,
+                      old_layout: Layout,
+                      new_layout: Layout) -> Result<*mut u8, AllocErr> {
+        (&*self).realloc(ptr, old_layout, new_layout)
+    }
 
-        fn oom(&mut self, err: AllocErr) -> ! {
-            (&*self).oom(err)
-        }
+    fn oom(&mut self, err: AllocErr) -> ! {
+        (&*self).oom(err)
+    }
 
-        #[inline]
-        fn usable_size(&self, layout: &Layout) -> (usize, usize) {
-            (&self).usable_size(layout)
-        }
+    #[inline]
+    fn usable_size(&self, layout: &Layout) -> (usize, usize) {
+        (&self).usable_size(layout)
+    }
 
-        #[inline]
-        unsafe fn alloc_excess(&mut self, layout: Layout) -> Result<Excess, AllocErr> {
-            (&*self).alloc_excess(layout)
-        }
+    #[inline]
+    unsafe fn alloc_excess(&mut self, layout: Layout) -> Result<Excess, AllocErr> {
+        (&*self).alloc_excess(layout)
+    }
 
-        #[inline]
-        unsafe fn realloc_excess(&mut self,
-                                 ptr: *mut u8,
-                                 layout: Layout,
-                                 new_layout: Layout) -> Result<Excess, AllocErr> {
-            (&*self).realloc_excess(ptr, layout, new_layout)
-        }
+    #[inline]
+    unsafe fn realloc_excess(&mut self,
+                             ptr: *mut u8,
+                             layout: Layout,
+                             new_layout: Layout) -> Result<Excess, AllocErr> {
+        (&*self).realloc_excess(ptr, layout, new_layout)
+    }
 
-        #[inline]
-        unsafe fn grow_in_place(&mut self,
-                                ptr: *mut u8,
-                                layout: Layout,
-                                new_layout: Layout) -> Result<(), CannotReallocInPlace> {
-            (&*self).grow_in_place(ptr, layout, new_layout)
-        }
+    #[inline]
+    unsafe fn grow_in_place(&mut self,
+                            ptr: *mut u8,
+                            layout: Layout,
+                            new_layout: Layout) -> Result<(), CannotReallocInPlace> {
+        (&*self).grow_in_place(ptr, layout, new_layout)
+    }
 
-        #[inline]
-        unsafe fn shrink_in_place(&mut self,
-                                  ptr: *mut u8,
-                                  layout: Layout,
-                                  new_layout: Layout) -> Result<(), CannotReallocInPlace> {
-            (&*self).shrink_in_place(ptr, layout, new_layout)
-        }
+    #[inline]
+    unsafe fn shrink_in_place(&mut self,
+                              ptr: *mut u8,
+                              layout: Layout,
+                              new_layout: Layout) -> Result<(), CannotReallocInPlace> {
+        (&*self).shrink_in_place(ptr, layout, new_layout)
     }
 }
 
-#[cfg(all(not(stage0), any(unix, target_os = "redox")))]
+#[cfg(any(unix, target_os = "redox"))]
 mod platform {
     extern crate libc;
 
@@ -135,8 +122,8 @@ mod platform {
     use core::ptr;
 
     use MIN_ALIGN;
-    use new::System;
-    use new::alloc::heap::{Alloc, AllocErr, Layout};
+    use System;
+    use alloc::heap::{Alloc, AllocErr, Layout};
 
     #[unstable(feature = "allocator_api", issue = "32838")]
     unsafe impl<'a> Alloc for &'a System {
@@ -272,15 +259,15 @@ mod platform {
     }
 }
 
-#[cfg(all(windows, not(stage0)))]
+#[cfg(windows)]
 #[allow(bad_style)]
 mod platform {
     use core::cmp;
     use core::ptr;
 
     use MIN_ALIGN;
-    use new::System;
-    use new::alloc::heap::{Alloc, AllocErr, Layout, CannotReallocInPlace};
+    use System;
+    use alloc::heap::{Alloc, AllocErr, Layout, CannotReallocInPlace};
 
     type LPVOID = *mut u8;
     type HANDLE = LPVOID;
diff --git a/src/liballoc_system/old.rs b/src/liballoc_system/old.rs
deleted file mode 100644
index 80aa4607594..00000000000
--- a/src/liballoc_system/old.rs
+++ /dev/null
@@ -1,268 +0,0 @@
-// Copyright 2017 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.
-
-#[no_mangle]
-pub unsafe extern fn __rust_alloc(size: usize,
-                                  align: usize,
-                                  err: *mut u8) -> *mut u8 {
-    let p = imp::allocate(size, align);
-    if p.is_null() {
-        __rust_oom(err);
-    }
-    p
-}
-
-#[no_mangle]
-pub unsafe extern fn __rust_oom(_err: *const u8) -> ! {
-    ::core::intrinsics::abort()
-}
-
-#[no_mangle]
-pub unsafe extern fn __rust_dealloc(ptr: *mut u8,
-                                    size: usize,
-                                    align: usize) {
-    imp::deallocate(ptr, size, align)
-}
-
-#[no_mangle]
-pub unsafe extern fn __rust_usable_size(size: usize,
-                                        _align: usize,
-                                        min: *mut usize,
-                                        max: *mut usize) {
-    *min = size;
-    *max = size;
-}
-
-#[no_mangle]
-pub unsafe extern fn __rust_realloc(ptr: *mut u8,
-                                    old_size: usize,
-                                    old_align: usize,
-                                    new_size: usize,
-                                    new_align: usize,
-                                    err: *mut u8) -> *mut u8 {
-    if new_align != old_align {
-        __rust_oom(err);
-    }
-    let p = imp::reallocate(ptr, old_size, new_size, new_align);
-    if p.is_null() {
-        __rust_oom(err);
-    }
-    p
-}
-
-#[no_mangle]
-pub unsafe extern fn __rust_alloc_zeroed(size: usize,
-                                         align: usize,
-                                         err: *mut u8) -> *mut u8 {
-    let p = imp::allocate_zeroed(size, align);
-    if p.is_null() {
-        __rust_oom(err);
-    }
-    p
-}
-
-#[no_mangle]
-pub unsafe extern fn __rust_alloc_excess(_size: usize,
-                                         _align: usize,
-                                         _excess: *mut usize,
-                                         err: *mut u8) -> *mut u8 {
-    __rust_oom(err);
-}
-
-#[no_mangle]
-pub unsafe extern fn __rust_realloc_excess(_ptr: *mut u8,
-                                           _old_size: usize,
-                                           _old_align: usize,
-                                           _new_size: usize,
-                                           _new_align: usize,
-                                           _excess: *mut usize,
-                                           err: *mut u8) -> *mut u8 {
-    __rust_oom(err);
-}
-
-#[no_mangle]
-pub unsafe extern fn __rust_grow_in_place(_ptr: *mut u8,
-                                          _old_size: usize,
-                                          _old_align: usize,
-                                          _new_size: usize,
-                                          _new_align: usize) -> u8 {
-    0
-}
-
-#[no_mangle]
-pub unsafe extern fn __rust_shrink_in_place(_ptr: *mut u8,
-                                            _old_size: usize,
-                                            _old_align: usize,
-                                            _new_size: usize,
-                                            _new_align: usize) -> u8 {
-    0
-}
-
-#[cfg(any(unix, target_os = "redox"))]
-mod imp {
-    extern crate libc;
-
-    use core::cmp;
-    use core::ptr;
-    use MIN_ALIGN;
-
-    pub unsafe fn allocate(size: usize, align: usize) -> *mut u8 {
-        if align <= MIN_ALIGN {
-            libc::malloc(size as libc::size_t) as *mut u8
-        } else {
-            aligned_malloc(size, align)
-        }
-    }
-
-    #[cfg(any(target_os = "android", target_os = "redox"))]
-    unsafe fn aligned_malloc(size: usize, align: usize) -> *mut u8 {
-        // On android we currently target API level 9 which unfortunately
-        // doesn't have the `posix_memalign` API used below. Instead we use
-        // `memalign`, but this unfortunately has the property on some systems
-        // where the memory returned cannot be deallocated by `free`!
-        //
-        // Upon closer inspection, however, this appears to work just fine with
-        // Android, so for this platform we should be fine to call `memalign`
-        // (which is present in API level 9). Some helpful references could
-        // possibly be chromium using memalign [1], attempts at documenting that
-        // memalign + free is ok [2] [3], or the current source of chromium
-        // which still uses memalign on android [4].
-        //
-        // [1]: https://codereview.chromium.org/10796020/
-        // [2]: https://code.google.com/p/android/issues/detail?id=35391
-        // [3]: https://bugs.chromium.org/p/chromium/issues/detail?id=138579
-        // [4]: https://chromium.googlesource.com/chromium/src/base/+/master/
-        //                                       /memory/aligned_memory.cc
-        libc::memalign(align as libc::size_t, size as libc::size_t) as *mut u8
-    }
-
-    #[cfg(not(any(target_os = "android", target_os = "redox")))]
-    unsafe fn aligned_malloc(size: usize, align: usize) -> *mut u8 {
-        let mut out = ptr::null_mut();
-        let ret = libc::posix_memalign(&mut out, align as libc::size_t, size as libc::size_t);
-        if ret != 0 {
-            ptr::null_mut()
-        } else {
-            out as *mut u8
-        }
-    }
-
-    pub unsafe fn allocate_zeroed(size: usize, align: usize) -> *mut u8 {
-        if align <= MIN_ALIGN {
-            libc::calloc(size as libc::size_t, 1) as *mut u8
-        } else {
-            let ptr = aligned_malloc(size, align);
-            if !ptr.is_null() {
-                ptr::write_bytes(ptr, 0, size);
-            }
-            ptr
-        }
-    }
-
-    pub unsafe fn reallocate(ptr: *mut u8, old_size: usize, size: usize, align: usize) -> *mut u8 {
-        if align <= MIN_ALIGN {
-            libc::realloc(ptr as *mut libc::c_void, size as libc::size_t) as *mut u8
-        } else {
-            let new_ptr = allocate(size, align);
-            if !new_ptr.is_null() {
-                ptr::copy(ptr, new_ptr, cmp::min(size, old_size));
-                deallocate(ptr, old_size, align);
-            }
-            new_ptr
-        }
-    }
-
-    pub unsafe fn deallocate(ptr: *mut u8, _old_size: usize, _align: usize) {
-        libc::free(ptr as *mut libc::c_void)
-    }
-}
-
-#[cfg(windows)]
-#[allow(bad_style)]
-mod imp {
-    use core::cmp::min;
-    use core::ptr::copy_nonoverlapping;
-    use MIN_ALIGN;
-
-    type LPVOID = *mut u8;
-    type HANDLE = LPVOID;
-    type SIZE_T = usize;
-    type DWORD = u32;
-    type BOOL = i32;
-
-    extern "system" {
-        fn GetProcessHeap() -> HANDLE;
-        fn HeapAlloc(hHeap: HANDLE, dwFlags: DWORD, dwBytes: SIZE_T) -> LPVOID;
-        fn HeapReAlloc(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPVOID, dwBytes: SIZE_T) -> LPVOID;
-        fn HeapFree(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPVOID) -> BOOL;
-        fn GetLastError() -> DWORD;
-    }
-
-    #[repr(C)]
-    struct Header(*mut u8);
-
-
-    const HEAP_ZERO_MEMORY: DWORD = 0x00000008;
-
-    unsafe fn get_header<'a>(ptr: *mut u8) -> &'a mut Header {
-        &mut *(ptr as *mut Header).offset(-1)
-    }
-
-    unsafe fn align_ptr(ptr: *mut u8, align: usize) -> *mut u8 {
-        let aligned = ptr.offset((align - (ptr as usize & (align - 1))) as isize);
-        *get_header(aligned) = Header(ptr);
-        aligned
-    }
-
-    #[inline]
-    unsafe fn allocate_with_flags(size: usize, align: usize, flags: DWORD) -> *mut u8 {
-        if align <= MIN_ALIGN {
-            HeapAlloc(GetProcessHeap(), flags, size as SIZE_T) as *mut u8
-        } else {
-            let ptr = HeapAlloc(GetProcessHeap(), flags, (size + align) as SIZE_T) as *mut u8;
-            if ptr.is_null() {
-                return ptr;
-            }
-            align_ptr(ptr, align)
-        }
-    }
-
-    pub unsafe fn allocate(size: usize, align: usize) -> *mut u8 {
-        allocate_with_flags(size, align, 0)
-    }
-
-    pub unsafe fn allocate_zeroed(size: usize, align: usize) -> *mut u8 {
-        allocate_with_flags(size, align, HEAP_ZERO_MEMORY)
-    }
-
-    pub unsafe fn reallocate(ptr: *mut u8, old_size: usize, size: usize, align: usize) -> *mut u8 {
-        if align <= MIN_ALIGN {
-            HeapReAlloc(GetProcessHeap(), 0, ptr as LPVOID, size as SIZE_T) as *mut u8
-        } else {
-            let new = allocate(size, align);
-            if !new.is_null() {
-                copy_nonoverlapping(ptr, new, min(size, old_size));
-                deallocate(ptr, old_size, align);
-            }
-            new
-        }
-    }
-
-    pub unsafe fn deallocate(ptr: *mut u8, _old_size: usize, align: usize) {
-        if align <= MIN_ALIGN {
-            let err = HeapFree(GetProcessHeap(), 0, ptr as LPVOID);
-            debug_assert!(err != 0, "Failed to free heap memory: {}", GetLastError());
-        } else {
-            let header = get_header(ptr);
-            let err = HeapFree(GetProcessHeap(), 0, header.0 as LPVOID);
-            debug_assert!(err != 0, "Failed to free heap memory: {}", GetLastError());
-        }
-    }
-}
diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs
index 981ab5b6c46..65c18d6d777 100644
--- a/src/libcore/intrinsics.rs
+++ b/src/libcore/intrinsics.rs
@@ -1229,7 +1229,6 @@ extern "rust-intrinsic" {
     /// let num_leading = unsafe { ctlz_nonzero(x) };
     /// assert_eq!(num_leading, 3);
     /// ```
-    #[cfg(not(stage0))]
     pub fn ctlz_nonzero<T>(x: T) -> T;
 
     /// Returns the number of trailing unset bits (zeroes) in an integer type `T`.
@@ -1273,7 +1272,6 @@ extern "rust-intrinsic" {
     /// let num_trailing = unsafe { cttz_nonzero(x) };
     /// assert_eq!(num_trailing, 3);
     /// ```
-    #[cfg(not(stage0))]
     pub fn cttz_nonzero<T>(x: T) -> T;
 
     /// Reverses the bytes in an integer type `T`.
diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs
index e8e31ffea0b..546d2a21939 100644
--- a/src/libcore/lib.rs
+++ b/src/libcore/lib.rs
@@ -93,8 +93,6 @@
 #![feature(untagged_unions)]
 #![feature(unwind_attributes)]
 
-#![cfg_attr(stage0, feature(associated_consts))]
-
 #[prelude_import]
 #[allow(unused)]
 use prelude::v1::*;
diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs
index 0ebac027c39..185034a5313 100644
--- a/src/libcore/num/mod.rs
+++ b/src/libcore/num/mod.rs
@@ -2238,17 +2238,12 @@ macro_rules! uint_impl {
     }
 }
 
-#[cfg(stage0)]
-unsafe fn ctlz_nonzero<T>(x: T) -> T { intrinsics::ctlz(x) }
-#[cfg(not(stage0))]
-unsafe fn ctlz_nonzero<T>(x: T) -> T { intrinsics::ctlz_nonzero(x) }
-
 #[lang = "u8"]
 impl u8 {
     uint_impl! { u8, u8, 8,
         intrinsics::ctpop,
         intrinsics::ctlz,
-        ctlz_nonzero,
+        intrinsics::ctlz_nonzero,
         intrinsics::cttz,
         intrinsics::bswap,
         intrinsics::add_with_overflow,
@@ -2261,7 +2256,7 @@ impl u16 {
     uint_impl! { u16, u16, 16,
         intrinsics::ctpop,
         intrinsics::ctlz,
-        ctlz_nonzero,
+        intrinsics::ctlz_nonzero,
         intrinsics::cttz,
         intrinsics::bswap,
         intrinsics::add_with_overflow,
@@ -2274,7 +2269,7 @@ impl u32 {
     uint_impl! { u32, u32, 32,
         intrinsics::ctpop,
         intrinsics::ctlz,
-        ctlz_nonzero,
+        intrinsics::ctlz_nonzero,
         intrinsics::cttz,
         intrinsics::bswap,
         intrinsics::add_with_overflow,
@@ -2287,7 +2282,7 @@ impl u64 {
     uint_impl! { u64, u64, 64,
         intrinsics::ctpop,
         intrinsics::ctlz,
-        ctlz_nonzero,
+        intrinsics::ctlz_nonzero,
         intrinsics::cttz,
         intrinsics::bswap,
         intrinsics::add_with_overflow,
@@ -2300,7 +2295,7 @@ impl u128 {
     uint_impl! { u128, u128, 128,
         intrinsics::ctpop,
         intrinsics::ctlz,
-        ctlz_nonzero,
+        intrinsics::ctlz_nonzero,
         intrinsics::cttz,
         intrinsics::bswap,
         intrinsics::add_with_overflow,
@@ -2314,7 +2309,7 @@ impl usize {
     uint_impl! { usize, u16, 16,
         intrinsics::ctpop,
         intrinsics::ctlz,
-        ctlz_nonzero,
+        intrinsics::ctlz_nonzero,
         intrinsics::cttz,
         intrinsics::bswap,
         intrinsics::add_with_overflow,
@@ -2327,7 +2322,7 @@ impl usize {
     uint_impl! { usize, u32, 32,
         intrinsics::ctpop,
         intrinsics::ctlz,
-        ctlz_nonzero,
+        intrinsics::ctlz_nonzero,
         intrinsics::cttz,
         intrinsics::bswap,
         intrinsics::add_with_overflow,
@@ -2341,7 +2336,7 @@ impl usize {
     uint_impl! { usize, u64, 64,
         intrinsics::ctpop,
         intrinsics::ctlz,
-        ctlz_nonzero,
+        intrinsics::ctlz_nonzero,
         intrinsics::cttz,
         intrinsics::bswap,
         intrinsics::add_with_overflow,
diff --git a/src/libcore/panicking.rs b/src/libcore/panicking.rs
index f5a7e78d0fa..4170d91e5fc 100644
--- a/src/libcore/panicking.rs
+++ b/src/libcore/panicking.rs
@@ -39,7 +39,7 @@
 use fmt;
 
 #[cold] #[inline(never)] // this is the slow path, always
-#[cfg_attr(not(stage0), lang = "panic")]
+#[lang = "panic"]
 pub fn panic(expr_file_line_col: &(&'static str, &'static str, u32, u32)) -> ! {
     // Use Arguments::new_v1 instead of format_args!("{}", expr) to potentially
     // reduce size overhead. The format_args! macro uses str's Display trait to
@@ -51,35 +51,14 @@ pub fn panic(expr_file_line_col: &(&'static str, &'static str, u32, u32)) -> ! {
     panic_fmt(fmt::Arguments::new_v1(&[expr], &[]), &(file, line, col))
 }
 
-// FIXME: remove when SNAP
-#[cold] #[inline(never)]
-#[cfg(stage0)]
-#[lang = "panic"]
-pub fn panic_old(expr_file_line: &(&'static str, &'static str, u32)) -> ! {
-    let (expr, file, line) = *expr_file_line;
-    let expr_file_line_col = (expr, file, line, 0);
-    panic(&expr_file_line_col)
-}
-
 #[cold] #[inline(never)]
-#[cfg_attr(not(stage0), lang = "panic_bounds_check")]
+#[lang = "panic_bounds_check"]
 fn panic_bounds_check(file_line_col: &(&'static str, u32, u32),
                      index: usize, len: usize) -> ! {
     panic_fmt(format_args!("index out of bounds: the len is {} but the index is {}",
                            len, index), file_line_col)
 }
 
-// FIXME: remove when SNAP
-#[cold] #[inline(never)]
-#[cfg(stage0)]
-#[lang = "panic_bounds_check"]
-fn panic_bounds_check_old(file_line: &(&'static str, u32),
-                     index: usize, len: usize) -> ! {
-    let (file, line) = *file_line;
-    panic_fmt(format_args!("index out of bounds: the len is {} but the index is {}",
-                           len, index), &(file, line, 0))
-}
-
 #[cold] #[inline(never)]
 pub fn panic_fmt(fmt: fmt::Arguments, file_line_col: &(&'static str, u32, u32)) -> ! {
     #[allow(improper_ctypes)]
diff --git a/src/libprofiler_builtins/lib.rs b/src/libprofiler_builtins/lib.rs
index 087cc444185..1fb2c6b7dbb 100644
--- a/src/libprofiler_builtins/lib.rs
+++ b/src/libprofiler_builtins/lib.rs
@@ -9,8 +9,8 @@
 // except according to those terms.
 
 #![no_std]
-#![cfg_attr(not(stage0), feature(profiler_runtime))]
-#![cfg_attr(not(stage0), profiler_runtime)]
+#![feature(profiler_runtime)]
+#![profiler_runtime]
 #![unstable(feature = "profiler_runtime_lib",
             reason = "internal implementation detail of rustc right now",
             issue = "0")]
diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs
index e0317e5e7f8..5b0760e561e 100644
--- a/src/librustc/lib.rs
+++ b/src/librustc/lib.rs
@@ -41,8 +41,6 @@
 #![feature(trace_macros)]
 #![feature(test)]
 
-#![cfg_attr(stage0, feature(associated_consts))]
-
 #![recursion_limit="256"]
 
 extern crate arena;
diff --git a/src/librustc_asan/lib.rs b/src/librustc_asan/lib.rs
index e987b1f335e..3429e3bda0f 100644
--- a/src/librustc_asan/lib.rs
+++ b/src/librustc_asan/lib.rs
@@ -9,10 +9,10 @@
 // except according to those terms.
 
 #![sanitizer_runtime]
-#![feature(sanitizer_runtime)]
 #![feature(alloc_system)]
-#![cfg_attr(not(stage0), feature(allocator_api))]
-#![cfg_attr(not(stage0), feature(global_allocator))]
+#![feature(allocator_api)]
+#![feature(global_allocator)]
+#![feature(sanitizer_runtime)]
 #![feature(staged_api)]
 #![no_std]
 #![unstable(feature = "sanitizer_runtime_lib",
@@ -21,9 +21,7 @@
 
 extern crate alloc_system;
 
-#[cfg(not(stage0))]
 use alloc_system::System;
 
-#[cfg(not(stage0))]
 #[global_allocator]
 static ALLOC: System = System;
diff --git a/src/librustc_bitflags/lib.rs b/src/librustc_bitflags/lib.rs
index 83660714af7..73125655792 100644
--- a/src/librustc_bitflags/lib.rs
+++ b/src/librustc_bitflags/lib.rs
@@ -14,8 +14,6 @@
 #![no_std]
 #![deny(warnings)]
 
-#![cfg_attr(stage0, feature(associated_consts))]
-
 //! A typesafe bitmask flag generator.
 
 #[cfg(test)]
diff --git a/src/librustc_borrowck/lib.rs b/src/librustc_borrowck/lib.rs
index 723df564419..7a63592828f 100644
--- a/src/librustc_borrowck/lib.rs
+++ b/src/librustc_borrowck/lib.rs
@@ -21,8 +21,6 @@
 #![feature(quote)]
 #![feature(rustc_diagnostic_macros)]
 
-#![cfg_attr(stage0, feature(associated_consts))]
-
 #[macro_use] extern crate log;
 #[macro_use] extern crate syntax;
 extern crate syntax_pos;
diff --git a/src/librustc_data_structures/lib.rs b/src/librustc_data_structures/lib.rs
index 5d856597cad..0a74fb8dc86 100644
--- a/src/librustc_data_structures/lib.rs
+++ b/src/librustc_data_structures/lib.rs
@@ -36,9 +36,6 @@
 #![feature(specialization)]
 #![feature(manually_drop)]
 
-#![cfg_attr(stage0, feature(associated_consts))]
-#![cfg_attr(stage0, feature(struct_field_attributes))]
-
 #![cfg_attr(unix, feature(libc))]
 #![cfg_attr(test, feature(test))]
 
diff --git a/src/librustc_llvm/lib.rs b/src/librustc_llvm/lib.rs
index 947e433fdb9..5b823f91f5f 100644
--- a/src/librustc_llvm/lib.rs
+++ b/src/librustc_llvm/lib.rs
@@ -27,8 +27,6 @@
 #![feature(link_args)]
 #![feature(static_nobundle)]
 
-#![cfg_attr(stage0, feature(associated_consts))]
-
 extern crate libc;
 #[macro_use]
 #[no_link]
diff --git a/src/librustc_lsan/lib.rs b/src/librustc_lsan/lib.rs
index e987b1f335e..81a09e7e21a 100644
--- a/src/librustc_lsan/lib.rs
+++ b/src/librustc_lsan/lib.rs
@@ -11,8 +11,8 @@
 #![sanitizer_runtime]
 #![feature(sanitizer_runtime)]
 #![feature(alloc_system)]
-#![cfg_attr(not(stage0), feature(allocator_api))]
-#![cfg_attr(not(stage0), feature(global_allocator))]
+#![feature(allocator_api)]
+#![feature(global_allocator)]
 #![feature(staged_api)]
 #![no_std]
 #![unstable(feature = "sanitizer_runtime_lib",
@@ -21,9 +21,7 @@
 
 extern crate alloc_system;
 
-#[cfg(not(stage0))]
 use alloc_system::System;
 
-#[cfg(not(stage0))]
 #[global_allocator]
 static ALLOC: System = System;
diff --git a/src/librustc_mir/lib.rs b/src/librustc_mir/lib.rs
index bb176777332..912c2043390 100644
--- a/src/librustc_mir/lib.rs
+++ b/src/librustc_mir/lib.rs
@@ -27,8 +27,6 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
 #![feature(collection_placement)]
 #![feature(nonzero)]
 
-#![cfg_attr(stage0, feature(associated_consts))]
-
 #[macro_use] extern crate log;
 extern crate graphviz as dot;
 #[macro_use]
diff --git a/src/librustc_msan/lib.rs b/src/librustc_msan/lib.rs
index e987b1f335e..81a09e7e21a 100644
--- a/src/librustc_msan/lib.rs
+++ b/src/librustc_msan/lib.rs
@@ -11,8 +11,8 @@
 #![sanitizer_runtime]
 #![feature(sanitizer_runtime)]
 #![feature(alloc_system)]
-#![cfg_attr(not(stage0), feature(allocator_api))]
-#![cfg_attr(not(stage0), feature(global_allocator))]
+#![feature(allocator_api)]
+#![feature(global_allocator)]
 #![feature(staged_api)]
 #![no_std]
 #![unstable(feature = "sanitizer_runtime_lib",
@@ -21,9 +21,7 @@
 
 extern crate alloc_system;
 
-#[cfg(not(stage0))]
 use alloc_system::System;
 
-#[cfg(not(stage0))]
 #[global_allocator]
 static ALLOC: System = System;
diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs
index 64a88854fd6..7fdba11300b 100644
--- a/src/librustc_resolve/lib.rs
+++ b/src/librustc_resolve/lib.rs
@@ -18,8 +18,6 @@
 
 #![feature(rustc_diagnostic_macros)]
 
-#![cfg_attr(stage0, feature(associated_consts))]
-
 #[macro_use]
 extern crate log;
 #[macro_use]
diff --git a/src/librustc_trans/lib.rs b/src/librustc_trans/lib.rs
index 3038c7d6c78..70337a91731 100644
--- a/src/librustc_trans/lib.rs
+++ b/src/librustc_trans/lib.rs
@@ -34,8 +34,6 @@
 #![feature(slice_patterns)]
 #![feature(conservative_impl_trait)]
 
-#![cfg_attr(stage0, feature(associated_consts))]
-
 use rustc::dep_graph::WorkProduct;
 use syntax_pos::symbol::Symbol;
 
diff --git a/src/libstd/heap.rs b/src/libstd/heap.rs
index 83bd3b04b4d..d76ab31862b 100644
--- a/src/libstd/heap.rs
+++ b/src/libstd/heap.rs
@@ -13,10 +13,9 @@
 #![unstable(issue = "32838", feature = "allocator_api")]
 
 pub use alloc::heap::{Heap, Alloc, Layout, Excess, CannotReallocInPlace, AllocErr};
-#[cfg(not(stage0))]
 pub use alloc_system::System;
 
-#[cfg(all(not(stage0), not(test)))]
+#[cfg(not(test))]
 #[doc(hidden)]
 pub mod __default_lib_allocator {
     use super::{System, Layout, Alloc, AllocErr};
diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs
index a012f2f42c1..7584d753240 100644
--- a/src/libstd/lib.rs
+++ b/src/libstd/lib.rs
@@ -318,8 +318,7 @@
 #![feature(vec_push_all)]
 #![cfg_attr(test, feature(update_panic_count))]
 
-#![cfg_attr(not(stage0), default_lib_allocator)]
-#![cfg_attr(stage0, feature(associated_consts))]
+#![default_lib_allocator]
 
 // Explicitly import the prelude. The compiler uses this same unstable attribute
 // to import the prelude implicitly when building crates that depend on std.
diff --git a/src/libstd/thread/local.rs b/src/libstd/thread/local.rs
index be433e2b81e..0172f89e05b 100644
--- a/src/libstd/thread/local.rs
+++ b/src/libstd/thread/local.rs
@@ -110,7 +110,6 @@ impl<T: 'static> fmt::Debug for LocalKey<T> {
     }
 }
 
-#[cfg(not(stage0))]
 /// Declare a new thread local storage key of type [`std::thread::LocalKey`].
 ///
 /// # Syntax
@@ -152,7 +151,6 @@ macro_rules! thread_local {
     );
 }
 
-#[cfg(not(stage0))]
 #[doc(hidden)]
 #[unstable(feature = "thread_local_internals",
            reason = "should not be necessary",
@@ -185,71 +183,6 @@ macro_rules! __thread_local_inner {
     }
 }
 
-#[cfg(stage0)]
-/// Declare a new thread local storage key of type `std::thread::LocalKey`.
-#[macro_export]
-#[stable(feature = "rust1", since = "1.0.0")]
-#[allow_internal_unstable]
-macro_rules! thread_local {
-    // rule 0: empty (base case for the recursion)
-    () => {};
-
-    // rule 1: process multiple declarations where the first one is private
-    ($(#[$attr:meta])* static $name:ident: $t:ty = $init:expr; $($rest:tt)*) => (
-        thread_local!($(#[$attr])* static $name: $t = $init); // go to rule 2
-        thread_local!($($rest)*);
-    );
-
-    // rule 2: handle a single private declaration
-    ($(#[$attr:meta])* static $name:ident: $t:ty = $init:expr) => (
-        $(#[$attr])* static $name: $crate::thread::LocalKey<$t> =
-            __thread_local_inner!($t, $init);
-    );
-
-    // rule 3: handle multiple declarations where the first one is public
-    ($(#[$attr:meta])* pub static $name:ident: $t:ty = $init:expr; $($rest:tt)*) => (
-        thread_local!($(#[$attr])* pub static $name: $t = $init); // go to rule 4
-        thread_local!($($rest)*);
-    );
-
-    // rule 4: handle a single public declaration
-    ($(#[$attr:meta])* pub static $name:ident: $t:ty = $init:expr) => (
-        $(#[$attr])* pub static $name: $crate::thread::LocalKey<$t> =
-            __thread_local_inner!($t, $init);
-    );
-}
-
-#[cfg(stage0)]
-#[doc(hidden)]
-#[unstable(feature = "thread_local_internals",
-           reason = "should not be necessary",
-           issue = "0")]
-#[macro_export]
-#[allow_internal_unstable]
-macro_rules! __thread_local_inner {
-    ($t:ty, $init:expr) => {{
-        fn __init() -> $t { $init }
-
-        fn __getit() -> $crate::option::Option<
-            &'static $crate::cell::UnsafeCell<
-                $crate::option::Option<$t>>>
-        {
-            #[thread_local]
-            #[cfg(target_thread_local)]
-            static __KEY: $crate::thread::__FastLocalKeyInner<$t> =
-                $crate::thread::__FastLocalKeyInner::new();
-
-            #[cfg(not(target_thread_local))]
-            static __KEY: $crate::thread::__OsLocalKeyInner<$t> =
-                $crate::thread::__OsLocalKeyInner::new();
-
-            __KEY.get()
-        }
-
-        $crate::thread::LocalKey::new(__getit, __init)
-    }}
-}
-
 /// Indicator of the state of a thread local storage key.
 #[unstable(feature = "thread_local_state",
            reason = "state querying was recently added",
diff --git a/src/stage0.txt b/src/stage0.txt
index 12a56ba48e4..e49b301abbf 100644
--- a/src/stage0.txt
+++ b/src/stage0.txt
@@ -12,7 +12,7 @@
 # source tarball for a stable release you'll likely see `1.x.0` for rustc and
 # `0.x.0` for Cargo where they were released on `date`.
 
-date: 2017-06-15
+date: 2017-07-18
 rustc: beta
 cargo: beta
 
diff --git a/src/tools/cargo b/src/tools/cargo
-Subproject ffab51954ec32d55631c37a8730bb24915fc090
+Subproject 88aa6423a164774d09abc78a24e74e8e665f651