+From 601d24810e89efd42f7cd69d4a7ccecd4e35364d Mon Sep 17 00:00:00 2001
+From: Eric Huss <eric@huss.org>
+Date: Tue, 22 Jun 2021 22:10:25 -0700
+Subject: [PATCH 1/2] Don't dist miri on stable or beta.
+
+---
+ src/bootstrap/dist.rs | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs
+index 71ed0af4a7c04..e0c33f7357741 100644
+--- a/src/bootstrap/dist.rs
++++ b/src/bootstrap/dist.rs
+@@ -1171,6 +1171,9 @@ impl Step for Miri {
+ }
+
+ fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
++ if !builder.build.unstable_features() {
++ return None;
++ }
+ let compiler = self.compiler;
+ let target = self.target;
+ assert!(builder.config.extended);
+
+From 6aa79a34d87252deaae11e75663e5740a22f14ea Mon Sep 17 00:00:00 2001
+From: Eric Huss <eric@huss.org>
+Date: Wed, 23 Jun 2021 07:03:42 -0700
+Subject: [PATCH 2/2] Comment and include rust-analyzer.
+
+---
+ src/bootstrap/dist.rs | 9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs
+index e0c33f7357741..19895baf08f16 100644
+--- a/src/bootstrap/dist.rs
++++ b/src/bootstrap/dist.rs
+@@ -1072,6 +1072,12 @@ impl Step for RustAnalyzer {
+ }
+
+ fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
++ // This prevents rust-analyzer from being built for "dist" or "install"
++ // on the stable/beta channels. It is a nightly-only tool and should
++ // not be included.
++ if !builder.build.unstable_features() {
++ return None;
++ }
+ let compiler = self.compiler;
+ let target = self.target;
+ assert!(builder.config.extended);
+@@ -1171,6 +1177,9 @@ impl Step for Miri {
+ }
+
+ fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
++ // This prevents miri from being built for "dist" or "install"
++ // on the stable/beta channels. It is a nightly-only tool and should
++ // not be included.
+ if !builder.build.unstable_features() {
+ return None;
+ }
+From f698cacc33f0c9148bb3bb7501087b0d37e837ec Mon Sep 17 00:00:00 2001
+From: Eric Huss <eric@huss.org>
+Date: Fri, 9 Jul 2021 10:01:23 -0700
+Subject: [PATCH 1/3] Fix rust-analyzer install when not available.
+
+---
+ src/bootstrap/install.rs | 13 +++++++++----
+ 1 file changed, 9 insertions(+), 4 deletions(-)
+
+diff --git a/src/bootstrap/install.rs b/src/bootstrap/install.rs
+index 13ee909afd5e4..6f3054538a898 100644
+--- a/src/bootstrap/install.rs
++++ b/src/bootstrap/install.rs
+@@ -165,10 +165,15 @@ install!((self, builder, _config),
+ }
+ };
+ RustAnalyzer, "rust-analyzer", Self::should_build(_config), only_hosts: true, {
+- let tarball = builder
+- .ensure(dist::RustAnalyzer { compiler: self.compiler, target: self.target })
+- .expect("missing rust-analyzer");
+- install_sh(builder, "rust-analyzer", self.compiler.stage, Some(self.target), &tarball);
++ if let Some(tarball) =
++ builder.ensure(dist::RustAnalyzer { compiler: self.compiler, target: self.target })
++ {
++ install_sh(builder, "rust-analyzer", self.compiler.stage, Some(self.target), &tarball);
++ } else {
++ builder.info(
++ &format!("skipping Install rust-analyzer stage{} ({})", self.compiler.stage, self.target),
++ );
++ }
+ };
+ Clippy, "clippy", Self::should_build(_config), only_hosts: true, {
+ let tarball = builder.ensure(dist::Clippy { compiler: self.compiler, target: self.target });
+
+From 60ff731110815349dbc052c36e9cc50b9f12f32a Mon Sep 17 00:00:00 2001
+From: Eric Huss <eric@huss.org>
+Date: Sun, 11 Jul 2021 09:01:31 -0700
+Subject: [PATCH 2/3] Add comments why install steps should never fail.
+
+---
+ src/bootstrap/install.rs | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/src/bootstrap/install.rs b/src/bootstrap/install.rs
+index 6f3054538a898..2ac9d3dda206f 100644
+--- a/src/bootstrap/install.rs
++++ b/src/bootstrap/install.rs
+@@ -139,11 +139,15 @@ macro_rules! install {
+
+ install!((self, builder, _config),
+ Docs, "src/doc", _config.docs, only_hosts: false, {
++ // `expect` should be safe, only None when config.docs is false,
++ // which is guarded in `should_run`
+ let tarball = builder.ensure(dist::Docs { host: self.target }).expect("missing docs");
+ install_sh(builder, "docs", self.compiler.stage, Some(self.target), &tarball);
+ };
+ Std, "library/std", true, only_hosts: false, {
+ for target in &builder.targets {
++ // `expect` should be safe, only None when host != build, but this
++ // only runs when host == build
+ let tarball = builder.ensure(dist::Std {
+ compiler: self.compiler,
+ target: *target
+@@ -217,6 +221,8 @@ install!((self, builder, _config),
+ }
+ };
+ Analysis, "analysis", Self::should_build(_config), only_hosts: false, {
++ // `expect` should be safe, only None with host != build, but this
++ // only uses the `build` compiler
+ let tarball = builder.ensure(dist::Analysis {
+ // Find the actual compiler (handling the full bootstrap option) which
+ // produced the save-analysis data because that data isn't copied
+
+From 166c147c2727cd6d6ad4d39c40c51273b8a63c96 Mon Sep 17 00:00:00 2001
+From: Eric Huss <eric@huss.org>
+Date: Mon, 12 Jul 2021 13:29:47 -0700
+Subject: [PATCH 3/3] Provide a better error when `x.py install src/doc`
+ doesn't work.
+
+---
+ src/bootstrap/install.rs | 10 ++++++----
+ 1 file changed, 6 insertions(+), 4 deletions(-)
+
+diff --git a/src/bootstrap/install.rs b/src/bootstrap/install.rs
+index 2ac9d3dda206f..8a1b6df0dafe3 100644
+--- a/src/bootstrap/install.rs
++++ b/src/bootstrap/install.rs
+@@ -139,10 +139,12 @@ macro_rules! install {
+
+ install!((self, builder, _config),
+ Docs, "src/doc", _config.docs, only_hosts: false, {
+- // `expect` should be safe, only None when config.docs is false,
+- // which is guarded in `should_run`
+- let tarball = builder.ensure(dist::Docs { host: self.target }).expect("missing docs");
+- install_sh(builder, "docs", self.compiler.stage, Some(self.target), &tarball);
++ if let Some(tarball) = builder.ensure(dist::Docs { host: self.target }) {
++ install_sh(builder, "docs", self.compiler.stage, Some(self.target), &tarball);
++ } else {
++ panic!("docs are not available to install, \
++ check that `build.docs` is true in `config.toml`");
++ }
+ };
+ Std, "library/std", true, only_hosts: false, {
+ for target in &builder.targets {