From 54989f13768b81c76ea9c3298f78b1e172317b43 Mon Sep 17 00:00:00 2001 From: konsti Date: Wed, 7 Aug 2024 15:22:56 +0200 Subject: [PATCH] Replace unreachable `todo!()` with `unreachable!()` in locking (#5857) Replace a `todo!()` that was unreachable with an `unreachable!()` and a proper comment. --- crates/uv-resolver/src/lock.rs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/crates/uv-resolver/src/lock.rs b/crates/uv-resolver/src/lock.rs index e6fec4bd9..0e86c51b4 100644 --- a/crates/uv-resolver/src/lock.rs +++ b/crates/uv-resolver/src/lock.rs @@ -1385,9 +1385,8 @@ enum Source { impl Source { fn from_resolved_dist(resolved_dist: &ResolvedDist) -> Source { match *resolved_dist { - // TODO: Do we want to try to lock already-installed distributions? - // Or should we return an error? - ResolvedDist::Installed(_) => todo!(), + // We pass empty installed packages for locking. + ResolvedDist::Installed(_) => unreachable!(), ResolvedDist::Installable(ref dist) => Source::from_dist(dist), } } @@ -1766,9 +1765,8 @@ impl SourceDist { annotated_dist: &AnnotatedDist, ) -> Result, LockError> { match annotated_dist.dist { - // TODO: Do we want to try to lock already-installed distributions? - // Or should we return an error? - ResolvedDist::Installed(_) => todo!(), + // We pass empty installed packages for locking. + ResolvedDist::Installed(_) => unreachable!(), ResolvedDist::Installable(ref dist) => { SourceDist::from_dist(id, dist, &annotated_dist.hashes) } @@ -2007,9 +2005,8 @@ struct Wheel { impl Wheel { fn from_annotated_dist(annotated_dist: &AnnotatedDist) -> Result, LockError> { match annotated_dist.dist { - // TODO: Do we want to try to lock already-installed distributions? - // Or should we return an error? - ResolvedDist::Installed(_) => todo!(), + // We pass empty installed packages for locking. + ResolvedDist::Installed(_) => unreachable!(), ResolvedDist::Installable(ref dist) => Wheel::from_dist(dist, &annotated_dist.hashes), } }