Skip to content

Commit 668dffe

Browse files
committed
Add method to Toolchain to help crater know what to uninstall.
1 parent 4f0def5 commit 668dffe

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/toolchain.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,25 @@ impl Toolchain {
178178
}),
179179
};
180180

181+
/// Returns whether or not this toolchain is needed by rustwide itself.
182+
///
183+
/// This toolchain is used for doing things like installing tools.
184+
///
185+
/// ```rust
186+
/// # use rustwide::Toolchain;
187+
/// let tc = Toolchain::dist("stable-x86_64-unknown-linux-gnu");
188+
/// assert!(tc.is_needed_by_rustwide());
189+
/// let tc = Toolchain::dist("nightly-x86_64-unknown-linux-gnu");
190+
/// assert!(!tc.is_needed_by_rustwide());
191+
/// ```
192+
pub fn is_needed_by_rustwide(&self) -> bool {
193+
match &self.inner {
194+
ToolchainInner::Dist(dist) => dist.name.starts_with(MAIN_TOOLCHAIN_NAME),
195+
#[cfg(feature = "unstable-toolchain-ci")]
196+
_ => false,
197+
}
198+
}
199+
181200
/// Create a new dist toolchain.
182201
///
183202
/// Dist toolchains are all the toolchains available through rustup and distributed from

0 commit comments

Comments
 (0)