Skip to content

Commit

Permalink
refactor(toml): remove unnecessary ? operators
Browse files Browse the repository at this point in the history
  • Loading branch information
weihanglo committed Apr 25, 2024
1 parent 8425305 commit ae37310
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/cargo/util/toml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1894,7 +1894,7 @@ fn resolve_source_id_from_dependency<P: ResolveToPath + Clone>(
name_in_toml: &str,
manifest_ctx: &mut ManifestContext<'_, '_>,
) -> CargoResult<SourceId> {
let new_source_id = match (
match (
orig.git.as_ref(),
orig.path.as_ref(),
orig.registry.as_deref(),
Expand Down Expand Up @@ -1945,7 +1945,7 @@ fn resolve_source_id_from_dependency<P: ResolveToPath + Clone>(
manifest_ctx.warnings.push(msg);
}

SourceId::for_git(&loc, reference)?
SourceId::for_git(&loc, reference)
}
(None, Some(path), _, _) => {
let path = path.resolve(manifest_ctx.gctx);
Expand All @@ -1960,20 +1960,18 @@ fn resolve_source_id_from_dependency<P: ResolveToPath + Clone>(
if manifest_ctx.source_id.is_path() {
let path = manifest_ctx.root.join(path);
let path = paths::normalize_path(&path);
SourceId::for_path(&path)?
SourceId::for_path(&path)
} else {
manifest_ctx.source_id
Ok(manifest_ctx.source_id)
}
}
(None, None, Some(registry), None) => SourceId::alt_registry(manifest_ctx.gctx, registry)?,
(None, None, Some(registry), None) => SourceId::alt_registry(manifest_ctx.gctx, registry),
(None, None, None, Some(registry_index)) => {
let url = registry_index.into_url()?;
SourceId::for_registry(&url)?
SourceId::for_registry(&url)
}
(None, None, None, None) => SourceId::crates_io(manifest_ctx.gctx)?,
};

Ok(new_source_id)
(None, None, None, None) => SourceId::crates_io(manifest_ctx.gctx),
}
}

pub trait ResolveToPath {
Expand Down

0 comments on commit ae37310

Please sign in to comment.