Skip to content

Commit

Permalink
Remove unreachable code branches
Browse files Browse the repository at this point in the history
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
  • Loading branch information
Rustin170506 committed Nov 3, 2022
1 parent ce3f722 commit 2637e08
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/cargo/ops/cargo_add/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,7 @@ fn resolve_dependency(
} 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 = packages.pop().expect("at least one package");
Dependency::from(package.summary())
};
selected
Expand Down Expand Up @@ -606,9 +604,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 2637e08

Please sign in to comment.