Skip to content

Commit 4abc0cf

Browse files
committed
publish: Simplify validate_dependencies() fn
1 parent d3509d8 commit 4abc0cf

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

src/controllers/krate/publish.rs

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -432,27 +432,22 @@ fn missing_metadata_error_message(missing: &[&str]) -> String {
432432

433433
#[instrument(skip_all)]
434434
pub fn validate_dependencies(deps: &[EncodableCrateDependency]) -> AppResult<()> {
435-
deps
436-
.iter()
437-
.map(|dep| {
438-
if let Some(registry) = &dep.registry {
439-
if !registry.is_empty() {
440-
return Err(cargo_err(&format_args!("Dependency `{}` is hosted on another registry. Cross-registry dependencies are not permitted on crates.io.", &*dep.name)));
441-
}
435+
for dep in deps {
436+
if let Some(registry) = &dep.registry {
437+
if !registry.is_empty() {
438+
return Err(cargo_err(&format_args!("Dependency `{}` is hosted on another registry. Cross-registry dependencies are not permitted on crates.io.", &*dep.name)));
442439
}
440+
}
443441

444-
if let Ok(version_req) = semver::VersionReq::parse(&dep.version_req.0) {
445-
if version_req == semver::VersionReq::STAR {
446-
return Err(cargo_err(&format_args!("wildcard (`*`) dependency constraints are not allowed \
447-
on crates.io. Crate with this problem: `{}` See https://doc.rust-lang.org/cargo/faq.html#can-\
448-
libraries-use--as-a-version-for-their-dependencies for more \
449-
information", &*dep.name)));
450-
}
442+
if let Ok(version_req) = semver::VersionReq::parse(&dep.version_req.0) {
443+
if version_req == semver::VersionReq::STAR {
444+
return Err(cargo_err(&format_args!("wildcard (`*`) dependency constraints are not allowed \
445+
on crates.io. Crate with this problem: `{}` See https://doc.rust-lang.org/cargo/faq.html#can-\
446+
libraries-use--as-a-version-for-their-dependencies for more \
447+
information", &*dep.name)));
451448
}
452-
453-
Ok(())
454-
})
455-
.collect::<Result<Vec<_>, _>>()?;
449+
}
450+
}
456451

457452
Ok(())
458453
}

0 commit comments

Comments
 (0)