From 2d9fe7ca701f72b35202bd48d5758dd5b5ef12fe Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Sun, 9 Nov 2025 10:37:16 -0600 Subject: [PATCH] Pin lock futures (#16643) These futures are quite large (~16,000 bytes) and adding new fields to the `ResolverOptions` in another pull request caused a lint error from Clippy. --- crates/uv/src/commands/project/add.rs | 70 ++++++++++++----------- crates/uv/src/commands/project/export.rs | 26 +++++---- crates/uv/src/commands/project/lock.rs | 36 ++++++------ crates/uv/src/commands/project/remove.rs | 26 +++++---- crates/uv/src/commands/project/run.rs | 68 +++++++++++----------- crates/uv/src/commands/project/sync.rs | 26 +++++---- crates/uv/src/commands/project/tree.rs | 26 +++++---- crates/uv/src/commands/project/version.rs | 52 +++++++++-------- 8 files changed, 176 insertions(+), 154 deletions(-) diff --git a/crates/uv/src/commands/project/add.rs b/crates/uv/src/commands/project/add.rs index 11c92010b..024281f85 100644 --- a/crates/uv/src/commands/project/add.rs +++ b/crates/uv/src/commands/project/add.rs @@ -990,24 +990,26 @@ async fn lock_and_sync( printer: Printer, preview: Preview, ) -> Result<(), ProjectError> { - let mut lock = project::lock::LockOperation::new( - if let LockCheck::Enabled(lock_check) = lock_check { - LockMode::Locked(target.interpreter(), lock_check) - } else { - LockMode::Write(target.interpreter()) - }, - &settings.resolver, - client_builder, - &lock_state, - Box::new(DefaultResolveLogger), - concurrency, - cache, - &WorkspaceCache::default(), - printer, - preview, + let mut lock = Box::pin( + project::lock::LockOperation::new( + if let LockCheck::Enabled(lock_check) = lock_check { + LockMode::Locked(target.interpreter(), lock_check) + } else { + LockMode::Write(target.interpreter()) + }, + &settings.resolver, + client_builder, + &lock_state, + Box::new(DefaultResolveLogger), + concurrency, + cache, + &WorkspaceCache::default(), + printer, + preview, + ) + .with_constraints(constraints) + .execute((&target).into()), ) - .with_constraints(constraints) - .execute((&target).into()) .await? .into_lock(); @@ -1112,23 +1114,25 @@ async fn lock_and_sync( // If the file was modified, we have to lock again, though the only expected change is // the addition of the minimum version specifiers. - lock = project::lock::LockOperation::new( - if let LockCheck::Enabled(lock_check) = lock_check { - LockMode::Locked(target.interpreter(), lock_check) - } else { - LockMode::Write(target.interpreter()) - }, - &settings.resolver, - client_builder, - &lock_state, - Box::new(SummaryResolveLogger), - concurrency, - cache, - &WorkspaceCache::default(), - printer, - preview, + lock = Box::pin( + project::lock::LockOperation::new( + if let LockCheck::Enabled(lock_check) = lock_check { + LockMode::Locked(target.interpreter(), lock_check) + } else { + LockMode::Write(target.interpreter()) + }, + &settings.resolver, + client_builder, + &lock_state, + Box::new(SummaryResolveLogger), + concurrency, + cache, + &WorkspaceCache::default(), + printer, + preview, + ) + .execute((&target).into()), ) - .execute((&target).into()) .await? .into_lock(); } diff --git a/crates/uv/src/commands/project/export.rs b/crates/uv/src/commands/project/export.rs index 23e5809ac..1028feb85 100644 --- a/crates/uv/src/commands/project/export.rs +++ b/crates/uv/src/commands/project/export.rs @@ -199,19 +199,21 @@ pub(crate) async fn export( let state = UniversalState::default(); // Lock the project. - let lock = match LockOperation::new( - mode, - &settings, - &client_builder, - &state, - Box::new(DefaultResolveLogger), - concurrency, - cache, - &workspace_cache, - printer, - preview, + let lock = match Box::pin( + LockOperation::new( + mode, + &settings, + &client_builder, + &state, + Box::new(DefaultResolveLogger), + concurrency, + cache, + &workspace_cache, + printer, + preview, + ) + .execute((&target).into()), ) - .execute((&target).into()) .await { Ok(result) => result.into_lock(), diff --git a/crates/uv/src/commands/project/lock.rs b/crates/uv/src/commands/project/lock.rs index 900085cf4..e90b05ca3 100644 --- a/crates/uv/src/commands/project/lock.rs +++ b/crates/uv/src/commands/project/lock.rs @@ -190,20 +190,22 @@ pub(crate) async fn lock( let state = UniversalState::default(); // Perform the lock operation. - match LockOperation::new( - mode, - &settings, - &client_builder, - &state, - Box::new(DefaultResolveLogger), - concurrency, - cache, - &workspace_cache, - printer, - preview, + match Box::pin( + LockOperation::new( + mode, + &settings, + &client_builder, + &state, + Box::new(DefaultResolveLogger), + concurrency, + cache, + &workspace_cache, + printer, + preview, + ) + .with_refresh(&refresh) + .execute(target), ) - .with_refresh(&refresh) - .execute(target) .await { Ok(lock) => { @@ -355,7 +357,7 @@ impl<'env> LockOperation<'env> { .ok_or_else(|| ProjectError::MissingLockfile)?; // Perform the lock operation, but don't write the lockfile to disk. - let result = do_lock( + let result = Box::pin(do_lock( target, interpreter, Some(existing), @@ -370,7 +372,7 @@ impl<'env> LockOperation<'env> { self.workspace_cache, self.printer, self.preview, - ) + )) .await?; // If the lockfile changed, return an error. @@ -399,7 +401,7 @@ impl<'env> LockOperation<'env> { }; // Perform the lock operation. - let result = do_lock( + let result = Box::pin(do_lock( target, interpreter, existing, @@ -414,7 +416,7 @@ impl<'env> LockOperation<'env> { self.workspace_cache, self.printer, self.preview, - ) + )) .await?; // If the lockfile changed, write it to disk. diff --git a/crates/uv/src/commands/project/remove.rs b/crates/uv/src/commands/project/remove.rs index c67a231d9..6487c5484 100644 --- a/crates/uv/src/commands/project/remove.rs +++ b/crates/uv/src/commands/project/remove.rs @@ -301,19 +301,21 @@ pub(crate) async fn remove( let state = UniversalState::default(); // Lock and sync the environment, if necessary. - let lock = match project::lock::LockOperation::new( - mode, - &settings.resolver, - &client_builder, - &state, - Box::new(DefaultResolveLogger), - concurrency, - cache, - &WorkspaceCache::default(), - printer, - preview, + let lock = match Box::pin( + project::lock::LockOperation::new( + mode, + &settings.resolver, + &client_builder, + &state, + Box::new(DefaultResolveLogger), + concurrency, + cache, + &WorkspaceCache::default(), + printer, + preview, + ) + .execute((&target).into()), ) - .execute((&target).into()) .await { Ok(result) => result.into_lock(), diff --git a/crates/uv/src/commands/project/run.rs b/crates/uv/src/commands/project/run.rs index 02c75504e..e64fe62b5 100644 --- a/crates/uv/src/commands/project/run.rs +++ b/crates/uv/src/commands/project/run.rs @@ -271,23 +271,25 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl }; // Generate a lockfile. - let lock = match project::lock::LockOperation::new( - mode, - &settings.resolver, - &client_builder, - &lock_state, - if show_resolution { - Box::new(DefaultResolveLogger) - } else { - Box::new(SummaryResolveLogger) - }, - concurrency, - &cache, - &workspace_cache, - printer, - preview, + let lock = match Box::pin( + project::lock::LockOperation::new( + mode, + &settings.resolver, + &client_builder, + &lock_state, + if show_resolution { + Box::new(DefaultResolveLogger) + } else { + Box::new(SummaryResolveLogger) + }, + concurrency, + &cache, + &workspace_cache, + printer, + preview, + ) + .execute(target), ) - .execute(target) .await { Ok(result) => result.into_lock(), @@ -748,23 +750,25 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl LockMode::Write(venv.interpreter()) }; - let result = match project::lock::LockOperation::new( - mode, - &settings.resolver, - &client_builder, - &lock_state, - if show_resolution { - Box::new(DefaultResolveLogger) - } else { - Box::new(SummaryResolveLogger) - }, - concurrency, - &cache, - &workspace_cache, - printer, - preview, + let result = match Box::pin( + project::lock::LockOperation::new( + mode, + &settings.resolver, + &client_builder, + &lock_state, + if show_resolution { + Box::new(DefaultResolveLogger) + } else { + Box::new(SummaryResolveLogger) + }, + concurrency, + &cache, + &workspace_cache, + printer, + preview, + ) + .execute(project.workspace().into()), ) - .execute(project.workspace().into()) .await { Ok(result) => result, diff --git a/crates/uv/src/commands/project/sync.rs b/crates/uv/src/commands/project/sync.rs index 833c560fd..6ee926daf 100644 --- a/crates/uv/src/commands/project/sync.rs +++ b/crates/uv/src/commands/project/sync.rs @@ -331,19 +331,21 @@ pub(crate) async fn sync( SyncTarget::Script(script) => LockTarget::from(script), }; - let outcome = match LockOperation::new( - mode, - &settings.resolver, - &client_builder, - &state, - Box::new(DefaultResolveLogger), - concurrency, - cache, - &workspace_cache, - printer, - preview, + let outcome = match Box::pin( + LockOperation::new( + mode, + &settings.resolver, + &client_builder, + &state, + Box::new(DefaultResolveLogger), + concurrency, + cache, + &workspace_cache, + printer, + preview, + ) + .execute(lock_target), ) - .execute(lock_target) .await { Ok(result) => Outcome::Success(result), diff --git a/crates/uv/src/commands/project/tree.rs b/crates/uv/src/commands/project/tree.rs index e2d6bf6f2..d75c66d84 100644 --- a/crates/uv/src/commands/project/tree.rs +++ b/crates/uv/src/commands/project/tree.rs @@ -139,19 +139,21 @@ pub(crate) async fn tree( let state = UniversalState::default(); // Update the lockfile, if necessary. - let lock = match LockOperation::new( - mode, - &settings, - client_builder, - &state, - Box::new(DefaultResolveLogger), - concurrency, - cache, - &WorkspaceCache::default(), - printer, - preview, + let lock = match Box::pin( + LockOperation::new( + mode, + &settings, + client_builder, + &state, + Box::new(DefaultResolveLogger), + concurrency, + cache, + &WorkspaceCache::default(), + printer, + preview, + ) + .execute(target), ) - .execute(target) .await { Ok(result) => result.into_lock(), diff --git a/crates/uv/src/commands/project/version.rs b/crates/uv/src/commands/project/version.rs index e19011092..0f5441f2a 100644 --- a/crates/uv/src/commands/project/version.rs +++ b/crates/uv/src/commands/project/version.rs @@ -450,19 +450,21 @@ async fn print_frozen_version( let state = UniversalState::default(); // Lock and sync the environment, if necessary. - let lock = match project::lock::LockOperation::new( - LockMode::Frozen, - &settings.resolver, - &client_builder, - &state, - Box::new(DefaultResolveLogger), - concurrency, - cache, - &WorkspaceCache::default(), - printer, - preview, + let lock = match Box::pin( + project::lock::LockOperation::new( + LockMode::Frozen, + &settings.resolver, + &client_builder, + &state, + Box::new(DefaultResolveLogger), + concurrency, + cache, + &WorkspaceCache::default(), + printer, + preview, + ) + .execute((&target).into()), ) - .execute((&target).into()) .await { Ok(result) => result.into_lock(), @@ -590,19 +592,21 @@ async fn lock_and_sync( let workspace_cache = WorkspaceCache::default(); // Lock and sync the environment, if necessary. - let lock = match project::lock::LockOperation::new( - mode, - &settings.resolver, - &client_builder, - &state, - Box::new(DefaultResolveLogger), - concurrency, - cache, - &workspace_cache, - printer, - preview, + let lock = match Box::pin( + project::lock::LockOperation::new( + mode, + &settings.resolver, + &client_builder, + &state, + Box::new(DefaultResolveLogger), + concurrency, + cache, + &workspace_cache, + printer, + preview, + ) + .execute((&target).into()), ) - .execute((&target).into()) .await { Ok(result) => result.into_lock(),