Skip to content

Commit

Permalink
refactor(config)!: make toolchain_from_partial() sync
Browse files Browse the repository at this point in the history
  • Loading branch information
rami3l committed Aug 9, 2024
1 parent e0b5727 commit bfa64d3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
16 changes: 8 additions & 8 deletions src/cli/rustup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,7 @@ async fn target_list(
quiet: bool,
) -> Result<utils::ExitCode> {
// downcasting required because the toolchain files can name any toolchain
let distributable = DistributableToolchain::from_partial(toolchain, cfg).await?;
let distributable = DistributableToolchain::from_partial(toolchain, cfg)?;
common::list_items(
distributable,
|c| {
Expand All @@ -1124,7 +1124,7 @@ async fn target_add(
// isn't a feature yet.
// list_components *and* add_component would both be inappropriate for
// custom toolchains.
let distributable = DistributableToolchain::from_partial(toolchain, cfg).await?;
let distributable = DistributableToolchain::from_partial(toolchain, cfg)?;
let components = distributable.components()?;

if targets.contains(&"all".to_string()) {
Expand Down Expand Up @@ -1168,7 +1168,7 @@ async fn target_remove(
targets: Vec<String>,
toolchain: Option<PartialToolchainDesc>,
) -> Result<utils::ExitCode> {
let distributable = DistributableToolchain::from_partial(toolchain, cfg).await?;
let distributable = DistributableToolchain::from_partial(toolchain, cfg)?;

for target in targets {
let target = TargetTriple::new(target);
Expand Down Expand Up @@ -1204,7 +1204,7 @@ async fn component_list(
quiet: bool,
) -> Result<utils::ExitCode> {
// downcasting required because the toolchain files can name any toolchain
let distributable = DistributableToolchain::from_partial(toolchain, cfg).await?;
let distributable = DistributableToolchain::from_partial(toolchain, cfg)?;
common::list_items(
distributable,
|c| Some(&c.name),
Expand All @@ -1220,7 +1220,7 @@ async fn component_add(
toolchain: Option<PartialToolchainDesc>,
target: Option<String>,
) -> Result<utils::ExitCode> {
let distributable = DistributableToolchain::from_partial(toolchain, cfg).await?;
let distributable = DistributableToolchain::from_partial(toolchain, cfg)?;
let target = get_target(target, &distributable);

for component in &components {
Expand All @@ -1246,7 +1246,7 @@ async fn component_remove(
toolchain: Option<PartialToolchainDesc>,
target: Option<String>,
) -> Result<utils::ExitCode> {
let distributable = DistributableToolchain::from_partial(toolchain, cfg).await?;
let distributable = DistributableToolchain::from_partial(toolchain, cfg)?;
let target = get_target(target, &distributable);

for component in &components {
Expand Down Expand Up @@ -1447,7 +1447,7 @@ async fn doc(
mut topic: Option<&str>,
doc_page: &DocPage,
) -> Result<utils::ExitCode> {
let toolchain = cfg.toolchain_from_partial(toolchain).await?;
let toolchain = cfg.toolchain_from_partial(toolchain)?;

if let Ok(distributable) = DistributableToolchain::try_from(&toolchain) {
if let [_] = distributable
Expand Down Expand Up @@ -1508,7 +1508,7 @@ async fn man(
command: &str,
toolchain: Option<PartialToolchainDesc>,
) -> Result<utils::ExitCode> {
let toolchain = cfg.toolchain_from_partial(toolchain).await?;
let toolchain = cfg.toolchain_from_partial(toolchain)?;
let path = toolchain.man_path();
utils::assert_is_directory(&path)?;

Expand Down
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ impl<'a> Cfg<'a> {
.transpose()?)
}

pub(crate) async fn toolchain_from_partial(
pub(crate) fn toolchain_from_partial(
&self,
toolchain: Option<PartialToolchainDesc>,
) -> anyhow::Result<Toolchain<'_>> {
Expand Down
6 changes: 2 additions & 4 deletions src/toolchain/distributable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,11 @@ pub(crate) struct DistributableToolchain<'a> {
}

impl<'a> DistributableToolchain<'a> {
pub(crate) async fn from_partial(
pub(crate) fn from_partial(
toolchain: Option<PartialToolchainDesc>,
cfg: &'a Cfg<'a>,
) -> anyhow::Result<Self> {
Ok(Self::try_from(
&cfg.toolchain_from_partial(toolchain).await?,
)?)
Ok(Self::try_from(&cfg.toolchain_from_partial(toolchain)?)?)
}

pub(crate) fn new(cfg: &'a Cfg<'a>, desc: ToolchainDesc) -> Result<Self, RustupError> {
Expand Down

0 comments on commit bfa64d3

Please sign in to comment.