Skip to content

Commit

Permalink
Remove unreachable branches
Browse files Browse the repository at this point in the history
Signed-off-by: hi-rustin <[email protected]>
  • Loading branch information
Rustin170506 committed Nov 3, 2022
1 parent 6b24d5c commit 62bfdf0
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/cargo/ops/cargo_add/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,7 @@ fn resolve_dependency(
selected
} else {
let source = crate::sources::PathSource::new(&path, src.source_id()?, config);
let mut packages = source.read_packages()?;
let package = packages
.pop()
.ok_or(anyhow::anyhow!("no packages found at `{src}`"))?;
let package = source.read_packages()?.pop().expect("at least one package");
Dependency::from(package.summary())
};
selected
Expand Down Expand Up @@ -606,9 +603,7 @@ fn infer_package_for_git_source(
src: &dyn std::fmt::Display,
) -> CargoResult<Package> {
let package = match packages.len() {
0 => {
anyhow::bail!("no packages found at `{src}`");
}
0 => unreachable!(),
1 => packages.pop().expect("match ensured element is present"),
_ => {
let mut names: Vec<_> = packages
Expand Down

0 comments on commit 62bfdf0

Please sign in to comment.