From 0343a47216ebff83e49c0e285083d04dde1576c3 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Fri, 22 May 2026 01:00:03 +0200 Subject: [PATCH] chore(pacquet): fix Doc + Dylint CI failures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Doc job (`RUSTDOCFLAGS=-D warnings`): - `cli/src/state.rs`: drop the doc-link to `pacquet_package_manager::PrefetchingResolver` (removed in the earlier batched-prefetch refactor); rewrite the comment to describe the current shape. - `resolving-npm-resolver/src/pick_package.rs`: replace the unresolved `ResolveResult::manifest` link in `PickedManifestCache`'s doc with a fully-qualified path through `pacquet_resolving_resolver_base`. - `resolving-npm-resolver/src/fetch_full_metadata.rs`: disambiguate the `crate::pick_package` link on `FetchFullMetadataOutcome` — the name resolves to both the function and the module, so route through `crate::pick_package()` and drop the bracketed link around the helper function name. Dylint job (Perfectionist lints): - `resolving-deps-resolver/src/resolve_dependency_tree.rs`: rename `lock_recoverable` to `lock_recoverable` so it doesn't trip `perfectionist::single-letter-generic`. - `resolving-deps-resolver/src/resolve_peers.rs`: rewrite `pkg.result.clone()` (now `Arc`) as `Arc::clone(&pkg.result)` so the refcount bump is explicit at the call site, per `perfectionist::arc-rc-clone`. - `resolving-npm-resolver/src/pick_package.rs`: replace the lone unicode `…` in the inline comment on the per-cache-key fetch serializer with ASCII `...`, per `perfectionist::unicode-ellipsis-in-comments`. --- pacquet/crates/cli/src/state.rs | 10 ++++------ .../src/resolve_dependency_tree.rs | 2 +- .../resolving-deps-resolver/src/resolve_peers.rs | 3 ++- .../src/fetch_full_metadata.rs | 5 +++-- .../resolving-npm-resolver/src/pick_package.rs | 16 ++++++++-------- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/pacquet/crates/cli/src/state.rs b/pacquet/crates/cli/src/state.rs index 7806cdc56c..5d69c8903c 100644 --- a/pacquet/crates/cli/src/state.rs +++ b/pacquet/crates/cli/src/state.rs @@ -11,12 +11,10 @@ use std::{path::PathBuf, sync::Arc}; /// Application state when running `pacquet run` or `pacquet install`. pub struct State { - /// Shared cache that store downloaded tarballs. Held behind - /// [`Arc`] so the resolve-time prefetch (see - /// [`pacquet_package_manager::PrefetchingResolver`]) can capture - /// an owned clone into the `tokio::spawn`ed background download - /// while every install sub-pipeline still takes a borrowed - /// `&MemCache` via deref. + /// Shared cache that storing downloaded tarballs. Held behind + /// [`Arc`] so every install sub-pipeline can share the same + /// handle without per-call clones; the per-package call takes a + /// borrowed `&MemCache` via deref. pub tarball_mem_cache: Arc, /// HTTP client to make HTTP requests. Held behind [`std::sync::Arc`] so /// the lockfile-verification gate can own a clone for the diff --git a/pacquet/crates/resolving-deps-resolver/src/resolve_dependency_tree.rs b/pacquet/crates/resolving-deps-resolver/src/resolve_dependency_tree.rs index 3d57876b12..42c0adac2f 100644 --- a/pacquet/crates/resolving-deps-resolver/src/resolve_dependency_tree.rs +++ b/pacquet/crates/resolving-deps-resolver/src/resolve_dependency_tree.rs @@ -23,7 +23,7 @@ use serde_json::Value; /// install can keep going after the unrelated panic that poisoned /// the lock — better than escalating into a hard install-wide /// failure. -fn lock_recoverable(mutex: &Mutex) -> MutexGuard<'_, T> { +fn lock_recoverable(mutex: &Mutex) -> MutexGuard<'_, Inner> { mutex.lock().unwrap_or_else(|err| err.into_inner()) } diff --git a/pacquet/crates/resolving-deps-resolver/src/resolve_peers.rs b/pacquet/crates/resolving-deps-resolver/src/resolve_peers.rs index b5f090094d..8217097f7f 100644 --- a/pacquet/crates/resolving-deps-resolver/src/resolve_peers.rs +++ b/pacquet/crates/resolving-deps-resolver/src/resolve_peers.rs @@ -31,6 +31,7 @@ //! on anyway. use std::collections::{BTreeMap, HashMap, HashSet}; +use std::sync::Arc; use node_semver::{Range, Version}; use pacquet_deps_path::{DepPath, PeerId, create_peer_dep_graph_hash}; @@ -489,7 +490,7 @@ impl<'tree> Walker<'tree> { .or_insert(DependenciesGraphNode { dep_path: dep_path.clone(), resolved_package_id: pkg.id.clone(), - resolve_result: pkg.result.clone(), + resolve_result: Arc::clone(&pkg.result), children: graph_children, peer_dependencies: pkg.peer_dependencies.clone(), transitive_peer_dependencies, diff --git a/pacquet/crates/resolving-npm-resolver/src/fetch_full_metadata.rs b/pacquet/crates/resolving-npm-resolver/src/fetch_full_metadata.rs index 26aa120da7..931c8a6ecb 100644 --- a/pacquet/crates/resolving-npm-resolver/src/fetch_full_metadata.rs +++ b/pacquet/crates/resolving-npm-resolver/src/fetch_full_metadata.rs @@ -66,8 +66,9 @@ pub struct FetchFullMetadataOptions<'a> { /// Outcome of a [`fetch_full_metadata`] call. Mirrors upstream's /// [`FetchMetadataResult | FetchMetadataNotModifiedResult`](https://github.com/pnpm/pnpm/blob/2a9bd897bf/resolving/npm-resolver/src/fetch.ts#L80-L86) /// union — the caller (today: only -/// [`maybe_upgrade_abbreviated_meta_for_release_age`](crate::pick_package)) -/// reacts differently to a 304 than to a 200. [`Package`] is boxed +/// `maybe_upgrade_abbreviated_meta_for_release_age` inside +/// [`crate::pick_package()`]) reacts differently to a 304 than to +/// a 200. [`Package`] is boxed /// so the size of the enum stays small even though a full packument /// can be many KB; mirrors the same boxing pattern used elsewhere in /// the crate when a large struct sits next to a unit variant. diff --git a/pacquet/crates/resolving-npm-resolver/src/pick_package.rs b/pacquet/crates/resolving-npm-resolver/src/pick_package.rs index fd11375026..8f5284062f 100644 --- a/pacquet/crates/resolving-npm-resolver/src/pick_package.rs +++ b/pacquet/crates/resolving-npm-resolver/src/pick_package.rs @@ -139,13 +139,13 @@ pub fn shared_packument_fetch_locker() -> PackumentFetchLocker { /// Per-`(pkg_name, version)` cache for the resolver's serialized /// `manifest` JSON. The npm resolver builds -/// [`ResolveResult::manifest`] via `serde_json::to_value(picked)`; -/// when many resolves pick the same version of the same package -/// (the common case for shared deps like `react`, `lodash`, …) -/// every duplicate would otherwise re-walk and re-allocate the -/// same JSON tree. Cache the `Arc` once per -/// `(pkg_name, version)` pair so the second pick onwards is an -/// `Arc::clone` instead of a full reserialise. +/// [`pacquet_resolving_resolver_base::ResolveResult`]'s `manifest` +/// field via `serde_json::to_value(picked)`; when many resolves +/// pick the same version of the same package (the common case for +/// shared deps like `react`, `lodash`, ...) every duplicate would +/// otherwise re-walk and re-allocate the same JSON tree. Cache the +/// `Arc` once per `(pkg_name, version)` pair so the second +/// pick onwards is an `Arc::clone` instead of a full reserialise. /// /// Shared across [`crate::NpmResolver`] and /// [`crate::NamedRegistryResolver`] for the same reasons @@ -419,7 +419,7 @@ pub async fn pick_package( } // Per-cache-key fetch serializer. Mirrors upstream's - // [`runLimited(pkgMirror, …)`](https://github.com/pnpm/pnpm/blob/f657b5cb44/resolving/npm-resolver/src/pickPackage.ts#L52-L64) + // [`runLimited(pkgMirror, ...)`](https://github.com/pnpm/pnpm/blob/f657b5cb44/resolving/npm-resolver/src/pickPackage.ts#L52-L64) // pLimit(1): concurrent picks for the same packument coalesce // into a single network fetch. The first caller for `cache_key` // acquires the permit and runs steps 2-5; the rest park here