Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

collapse nested if blocks #9613

Merged
merged 1 commit into from
Aug 6, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/cargo/core/compiler/context/mod.rs
Original file line number Diff line number Diff line change
@@ -195,12 +195,12 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
self.compilation
.binaries
.push(self.unit_output(unit, bindst));
} else if unit.target.is_cdylib() {
if !self.compilation.cdylibs.iter().any(|uo| uo.unit == *unit) {
self.compilation
.cdylibs
.push(self.unit_output(unit, bindst));
}
} else if unit.target.is_cdylib()
&& !self.compilation.cdylibs.iter().any(|uo| uo.unit == *unit)
{
self.compilation
.cdylibs
.push(self.unit_output(unit, bindst));
}
}

12 changes: 5 additions & 7 deletions src/cargo/ops/cargo_config.rs
Original file line number Diff line number Diff line change
@@ -51,13 +51,11 @@ pub struct GetOptions<'a> {
}

pub fn get(config: &Config, opts: &GetOptions<'_>) -> CargoResult<()> {
if opts.show_origin {
if !matches!(opts.format, ConfigFormat::Toml) {
bail!(
"the `{}` format does not support --show-origin, try the `toml` format instead",
opts.format
);
}
if opts.show_origin && !matches!(opts.format, ConfigFormat::Toml) {
bail!(
"the `{}` format does not support --show-origin, try the `toml` format instead",
opts.format
);
}
let key = match opts.key {
Some(key) => ConfigKey::from_str(key),
24 changes: 11 additions & 13 deletions src/cargo/ops/cargo_install.rs
Original file line number Diff line number Diff line change
@@ -211,20 +211,18 @@ fn install_one(
specify an alternate source",
src.path().display()
);
} else if src.path().join("cargo.toml").exists() {
bail!(
"`{}` does not contain a Cargo.toml file, but found cargo.toml please try to rename it to Cargo.toml. \
--path must point to a directory containing a Cargo.toml file.",
src.path().display()
)
} else {
if src.path().join("cargo.toml").exists() {
bail!(
"`{}` does not contain a Cargo.toml file, but found cargo.toml please try to rename it to Cargo.toml. \
--path must point to a directory containing a Cargo.toml file.",
src.path().display()
)
} else {
bail!(
"`{}` does not contain a Cargo.toml file. \
--path must point to a directory containing a Cargo.toml file.",
src.path().display()
)
}
bail!(
"`{}` does not contain a Cargo.toml file. \
--path must point to a directory containing a Cargo.toml file.",
src.path().display()
)
}
}
select_pkg(
16 changes: 7 additions & 9 deletions src/cargo/sources/registry/index.rs
Original file line number Diff line number Diff line change
@@ -602,15 +602,13 @@ impl Summaries {
// present and considered fresh this is where the debug assertions
// actually happens to verify that our cache is indeed fresh and
// computes exactly the same value as before.
if cfg!(debug_assertions) && cache_contents.is_some() {
if cache_bytes != cache_contents {
panic!(
"original cache contents:\n{:?}\n\
does not equal new cache contents:\n{:?}\n",
cache_contents.as_ref().map(|s| String::from_utf8_lossy(s)),
cache_bytes.as_ref().map(|s| String::from_utf8_lossy(s)),
);
}
if cfg!(debug_assertions) && cache_contents.is_some() && cache_bytes != cache_contents {
panic!(
"original cache contents:\n{:?}\n\
does not equal new cache contents:\n{:?}\n",
cache_contents.as_ref().map(|s| String::from_utf8_lossy(s)),
cache_bytes.as_ref().map(|s| String::from_utf8_lossy(s)),
);
}

// Once we have our `cache_bytes` which represents the `Summaries` we're
12 changes: 5 additions & 7 deletions src/cargo/util/config/target.rs
Original file line number Diff line number Diff line change
@@ -72,14 +72,12 @@ pub(super) fn get_target_applies_to_host(config: &Config) -> CargoResult<bool> {
} else {
Ok(!config.cli_unstable().host_config)
}
} else if config.cli_unstable().host_config {
anyhow::bail!(
"the -Zhost-config flag requires the -Ztarget-applies-to-host flag to be set"
);
} else {
if config.cli_unstable().host_config {
anyhow::bail!(
"the -Zhost-config flag requires the -Ztarget-applies-to-host flag to be set"
);
} else {
Ok(true)
}
Ok(true)
}
}