From 601fad0e8005cd7e1258e6496381af84cbca6690 Mon Sep 17 00:00:00 2001 From: Michael Rogenmoser Date: Thu, 12 Feb 2026 19:40:03 +0100 Subject: [PATCH 1/2] Fix a panic for unsuccessful dependency selection --- src/resolver.rs | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/resolver.rs b/src/resolver.rs index e47d2fe9c..8a58d79cf 100644 --- a/src/resolver.rs +++ b/src/resolver.rs @@ -991,16 +991,22 @@ impl<'ctx> DependencyResolver<'ctx> { .map(|(a, b, c)| (a, (b, c))) .collect::)>>(); // TODO: pick among possible sources. - debugln!( - "resolve: picking ref {} for `{}`", - src_map.first().unwrap().0, - dep.name - ); - State::Picked( - *src_map.first().unwrap().0, - src_map.first().unwrap().1.0, - src_map.into_iter().map(|(k, (_, ids))| (k, ids)).collect(), - ) + match src_map.first() { + Some(first) => { + debugln!("resolve: picking ref {} for `{}`", first.0, dep.name); + State::Picked( + *first.0, + first.1.0, + src_map.into_iter().map(|(k, (_, ids))| (k, ids)).collect(), + ) + } + None => { + return Err(Error::new(format!( + "No versions available for `{}`. This may be due to a conflict in the dependency requirements.", + dep.name + ))); + } + } } State::Picked(dref, id, map) => { if !dep.sources[dref].is_path() && !map[dref].contains(id) { From ab4f104a7d851baf7ccb91286b41e41b0d14a223 Mon Sep 17 00:00:00 2001 From: Michael Rogenmoser Date: Thu, 12 Feb 2026 19:57:35 +0100 Subject: [PATCH 2/2] Remove evaluation of debugln args in release --- src/cmd/path.rs | 4 ++-- src/error.rs | 4 +--- src/resolver.rs | 14 ++++++++------ src/sess.rs | 8 ++++---- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/cmd/path.rs b/src/cmd/path.rs index 90d0e28a9..5c0eedce6 100644 --- a/src/cmd/path.rs +++ b/src/cmd/path.rs @@ -45,7 +45,7 @@ pub fn run(sess: &Session, args: &PathArgs) -> Result<()> { if args.checkout || !paths.iter().all(|p| p.exists()) { debugln!("main: obtain checkouts {:?}", ids); let rt = Runtime::new()?; - let checkouts = rt + let _checkouts = rt .block_on(join_all( ids.iter() .map(|&(_, id)| io.checkout(id, false, &[])) @@ -53,7 +53,7 @@ pub fn run(sess: &Session, args: &PathArgs) -> Result<()> { )) .into_iter() .collect::>>()?; - debugln!("main: checkouts {:#?}", checkouts); + debugln!("main: checkouts {:#?}", _checkouts); } // Print paths diff --git a/src/error.rs b/src/error.rs index b67ad615d..02a1b9cc9 100644 --- a/src/error.rs +++ b/src/error.rs @@ -45,9 +45,7 @@ macro_rules! stageln { #[macro_export] #[cfg(not(debug_assertions))] macro_rules! debugln { - ($fmt:expr $(, $arg:expr)* $(,)?) => { $(let _ = $arg;)* } - // create an unused binding here so the compiler does not complain - // about the arguments to debugln! not being used in release builds. + ($($arg:tt)*) => {}; } /// Emit a diagnostic message. diff --git a/src/resolver.rs b/src/resolver.rs index 8a58d79cf..3bc5d6e96 100644 --- a/src/resolver.rs +++ b/src/resolver.rs @@ -148,15 +148,15 @@ impl<'ctx> DependencyResolver<'ctx> { &io, )?; - let mut iteration = 0; + let mut _iteration = 0; let mut any_changes = true; while any_changes { debugln!( "resolve: iteration {} table {:#?}", - iteration, + _iteration, TableDumper(&self.table) ); - iteration += 1; + _iteration += 1; // Constraint all dependencies with state `Open` -> `Constrained`. self.init()?; @@ -171,7 +171,7 @@ impl<'ctx> DependencyResolver<'ctx> { // Close the dependency set. any_changes |= self.close(&rt, &io)?; } - debugln!("resolve: resolved after {} iterations", iteration); + debugln!("resolve: resolved after {} iterations", _iteration); // Convert the resolved dependencies into a lockfile. let sess = self.sess; @@ -583,7 +583,7 @@ impl<'ctx> DependencyResolver<'ctx> { map }; - let src_cons_map = cons_map + let _src_cons_map = cons_map .iter() .map(|(name, cons)| { ( @@ -599,7 +599,7 @@ impl<'ctx> DependencyResolver<'ctx> { debugln!( "resolve: gathered constraints {:#?}", - ConstraintsDumper(&src_cons_map) + ConstraintsDumper(&_src_cons_map) ); // Impose the constraints on the dependencies. @@ -1207,6 +1207,7 @@ impl State { } } +#[allow(dead_code)] struct TableDumper<'a>(&'a IndexMap<&'a str, Dependency<'a>>); impl fmt::Debug for TableDumper<'_> { @@ -1238,6 +1239,7 @@ impl fmt::Debug for TableDumper<'_> { } } +#[allow(dead_code)] struct ConstraintsDumper<'a>( &'a IndexMap<&'a str, Vec<(&'a str, DependencyConstraint, DependencySource)>>, ); diff --git a/src/sess.rs b/src/sess.rs index e2c1bd747..f148bcede 100644 --- a/src/sess.rs +++ b/src/sess.rs @@ -145,13 +145,13 @@ impl<'ctx> Session<'ctx> { &self, name: &str, cfg: &config::Dependency, - calling_package: &str, + _calling_package: &str, ) -> DependencyRef { debugln!( "sess: load dependency `{}` as {:?} for package `{}`", name, cfg, - calling_package + _calling_package ); let src = DependencySource::from(cfg); self.deps @@ -952,10 +952,10 @@ impl<'io, 'sess: 'io, 'ctx: 'sess> SessionIo<'sess, 'ctx> { .await { Ok(r) => Ok(r), - Err(cause) => { + Err(_cause) => { debugln!( "checkout_git: failed to tag commit {:?}, attempting fetch.", - cause + _cause ); let pb = Some(ProgressHandler::new( self.sess.multiprogress.clone(),