Skip to content

Commit

Permalink
Better expect messages
Browse files Browse the repository at this point in the history
Signed-off-by: hi-rustin <[email protected]>
  • Loading branch information
Rustin170506 committed Nov 22, 2022
1 parent 62bfdf0 commit db3ebb6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/cargo/ops/cargo_add/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,10 @@ fn resolve_dependency(
selected
} else {
let source = crate::sources::PathSource::new(&path, src.source_id()?, config);
let package = source.read_packages()?.pop().expect("at least one package");
let package = source
.read_packages()?
.pop()
.expect("read_packages errors when no packages");
Dependency::from(package.summary())
};
selected
Expand Down Expand Up @@ -603,7 +606,10 @@ fn infer_package_for_git_source(
src: &dyn std::fmt::Display,
) -> CargoResult<Package> {
let package = match packages.len() {
0 => unreachable!(),
0 => unreachable!(
"this function should only be called with packages from `GitSource::read_packages` \
and that call should error for us when there are no packages"
),
1 => packages.pop().expect("match ensured element is present"),
_ => {
let mut names: Vec<_> = packages
Expand Down

0 comments on commit db3ebb6

Please sign in to comment.