Skip to content

Commit e4fc3b7

Browse files
committed
Inline utils::current_dir()
1 parent 0102b04 commit e4fc3b7

File tree

6 files changed

+11
-14
lines changed

6 files changed

+11
-14
lines changed

src/bin/rustup-init.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
1414
#![recursion_limit = "1024"]
1515

16-
use anyhow::{anyhow, Result};
16+
use anyhow::{anyhow, Context, Result};
1717
use cfg_if::cfg_if;
1818
// Public macros require availability of the internal symbols
1919
use rs_tracing::{
@@ -29,6 +29,7 @@ use rustup::cli::self_update;
2929
use rustup::cli::setup_mode;
3030
use rustup::currentprocess::{process, with_runtime, Process};
3131
use rustup::env_var::RUST_RECURSION_COUNT_MAX;
32+
use rustup::errors::RustupError;
3233
use rustup::is_proxyable_tools;
3334
use rustup::utils::utils::{self, ExitCode};
3435

@@ -115,7 +116,9 @@ async fn run_rustup_inner() -> Result<utils::ExitCode> {
115116

116117
// Before we do anything else, ensure we know where we are and who we
117118
// are because otherwise we cannot proceed usefully.
118-
let current_dir = utils::current_dir()?;
119+
let current_dir = process()
120+
.current_dir()
121+
.context(RustupError::LocatingWorkingDir)?;
119122
utils::current_exe()?;
120123

121124
match process().name().as_deref() {

src/currentprocess.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ impl Process {
106106
}
107107
}
108108

109-
pub(crate) fn current_dir(&self) -> io::Result<PathBuf> {
109+
pub fn current_dir(&self) -> io::Result<PathBuf> {
110110
match self {
111111
Process::OSProcess(_) => env::current_dir(),
112112
#[cfg(feature = "test")]

src/dist/dist.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ fn components_missing_msg(cs: &[Component], manifest: &ManifestV2, toolchain: &s
9696
}
9797

9898
#[derive(Debug, ThisError)]
99-
pub(crate) enum DistError {
99+
pub enum DistError {
100100
#[error("{}", components_missing_msg(.0, .1, .2))]
101101
ToolchainComponentsMissing(Vec<Component>, Box<ManifestV2>, String),
102102
#[error("no release found for '{0}'")]

src/errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use crate::{
2525
pub struct OperationError(pub anyhow::Error);
2626

2727
#[derive(ThisError, Debug)]
28-
pub(crate) enum RustupError {
28+
pub enum RustupError {
2929
#[error("partially downloaded file may have been damaged and was removed, please try again")]
3030
BrokenPartialFile,
3131
#[error("component download failed for {0}")]

src/toolchain/names.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ impl Display for MaybeOfficialToolchainName {
249249
/// like setting overrides, or that depend on configuration, like calculating
250250
/// the toolchain directory.
251251
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)]
252-
pub(crate) enum ToolchainName {
252+
pub enum ToolchainName {
253253
Custom(CustomToolchainName),
254254
Official(ToolchainDesc),
255255
}
@@ -396,7 +396,7 @@ impl Display for LocalToolchainName {
396396
/// A custom toolchain name, but not an official toolchain name
397397
/// (e.g. my-custom-toolchain)
398398
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)]
399-
pub(crate) struct CustomToolchainName(String);
399+
pub struct CustomToolchainName(String);
400400

401401
impl CustomToolchainName {
402402
fn validate(candidate: &str) -> Result<CustomToolchainName, InvalidName> {
@@ -433,7 +433,7 @@ impl Display for CustomToolchainName {
433433
/// code execution in a rust dir, so as a partial mitigation is limited to
434434
/// absolute paths.
435435
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)]
436-
pub(crate) struct PathBasedToolchainName(PathBuf, String);
436+
pub struct PathBasedToolchainName(PathBuf, String);
437437

438438
impl Display for PathBasedToolchainName {
439439
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {

src/utils/utils.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -491,12 +491,6 @@ pub(crate) fn make_executable(path: &Path) -> Result<()> {
491491
inner(path)
492492
}
493493

494-
pub fn current_dir() -> Result<PathBuf> {
495-
process()
496-
.current_dir()
497-
.context(RustupError::LocatingWorkingDir)
498-
}
499-
500494
pub fn current_exe() -> Result<PathBuf> {
501495
env::current_exe().context(RustupError::LocatingWorkingDir)
502496
}

0 commit comments

Comments
 (0)