diff --git a/src/bin/rustup-init.rs b/src/bin/rustup-init.rs index e27a3e4631..57b9057be5 100644 --- a/src/bin/rustup-init.rs +++ b/src/bin/rustup-init.rs @@ -13,7 +13,7 @@ #![recursion_limit = "1024"] -use anyhow::{anyhow, Result}; +use anyhow::{anyhow, Context, Result}; use cfg_if::cfg_if; // Public macros require availability of the internal symbols use rs_tracing::{ @@ -29,6 +29,7 @@ use rustup::cli::self_update; use rustup::cli::setup_mode; use rustup::currentprocess::{process, with_runtime, Process}; use rustup::env_var::RUST_RECURSION_COUNT_MAX; +use rustup::errors::RustupError; use rustup::is_proxyable_tools; use rustup::utils::utils::{self, ExitCode}; @@ -115,7 +116,9 @@ async fn run_rustup_inner() -> Result { // Before we do anything else, ensure we know where we are and who we // are because otherwise we cannot proceed usefully. - let current_dir = utils::current_dir()?; + let current_dir = process() + .current_dir() + .context(RustupError::LocatingWorkingDir)?; utils::current_exe()?; match process().name().as_deref() { diff --git a/src/currentprocess.rs b/src/currentprocess.rs index ba3d982e3d..27660bc85f 100644 --- a/src/currentprocess.rs +++ b/src/currentprocess.rs @@ -106,7 +106,7 @@ impl Process { } } - pub(crate) fn current_dir(&self) -> io::Result { + pub fn current_dir(&self) -> io::Result { match self { Process::OSProcess(_) => env::current_dir(), #[cfg(feature = "test")] diff --git a/src/dist/dist.rs b/src/dist/dist.rs index e3e0711b95..7a2139fa00 100644 --- a/src/dist/dist.rs +++ b/src/dist/dist.rs @@ -96,7 +96,7 @@ fn components_missing_msg(cs: &[Component], manifest: &ManifestV2, toolchain: &s } #[derive(Debug, ThisError)] -pub(crate) enum DistError { +pub enum DistError { #[error("{}", components_missing_msg(.0, .1, .2))] ToolchainComponentsMissing(Vec, Box, String), #[error("no release found for '{0}'")] diff --git a/src/errors.rs b/src/errors.rs index dafc05b857..3ed45506c3 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -25,7 +25,7 @@ use crate::{ pub struct OperationError(pub anyhow::Error); #[derive(ThisError, Debug)] -pub(crate) enum RustupError { +pub enum RustupError { #[error("partially downloaded file may have been damaged and was removed, please try again")] BrokenPartialFile, #[error("component download failed for {0}")] diff --git a/src/toolchain/names.rs b/src/toolchain/names.rs index 3dece6e5fb..ad1147acc2 100644 --- a/src/toolchain/names.rs +++ b/src/toolchain/names.rs @@ -249,7 +249,7 @@ impl Display for MaybeOfficialToolchainName { /// like setting overrides, or that depend on configuration, like calculating /// the toolchain directory. #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] -pub(crate) enum ToolchainName { +pub enum ToolchainName { Custom(CustomToolchainName), Official(ToolchainDesc), } @@ -396,7 +396,7 @@ impl Display for LocalToolchainName { /// A custom toolchain name, but not an official toolchain name /// (e.g. my-custom-toolchain) #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] -pub(crate) struct CustomToolchainName(String); +pub struct CustomToolchainName(String); impl CustomToolchainName { fn validate(candidate: &str) -> Result { @@ -433,7 +433,7 @@ impl Display for CustomToolchainName { /// code execution in a rust dir, so as a partial mitigation is limited to /// absolute paths. #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] -pub(crate) struct PathBasedToolchainName(PathBuf, String); +pub struct PathBasedToolchainName(PathBuf, String); impl Display for PathBasedToolchainName { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { diff --git a/src/utils/utils.rs b/src/utils/utils.rs index 592e5cec8e..42beb3c458 100644 --- a/src/utils/utils.rs +++ b/src/utils/utils.rs @@ -491,12 +491,6 @@ pub(crate) fn make_executable(path: &Path) -> Result<()> { inner(path) } -pub fn current_dir() -> Result { - process() - .current_dir() - .context(RustupError::LocatingWorkingDir) -} - pub fn current_exe() -> Result { env::current_exe().context(RustupError::LocatingWorkingDir) }