Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/socket-patch-cli/src/commands/scan/hosted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1218,7 +1218,7 @@ pub(super) async fn run_redirect(
.iter()
.map(|r| (r.writer.purl.clone(), r.writer.uuid.clone()))
.collect();
run_redirect_selected(
boxed_run_redirect_selected(
&args.common,
&args.vex,
prune,
Expand Down
52 changes: 26 additions & 26 deletions crates/socket-patch-cli/src/commands/scan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ use std::path::{Path, PathBuf};
use crate::args::{apply_env_toggles, GlobalArgs};
use crate::commands::vex::{generate_vex_from_manifest_path, VexEmbedArgs};
use crate::ecosystem_dispatch::{
crawl_ecosystems_with_npm, crawl_ecosystems_with_npm_roots, find_package_paths_for_path_scope,
partition_purls,
boxed, crawl_ecosystems_with_npm, crawl_ecosystems_with_npm_roots,
find_package_paths_for_path_scope, partition_purls,
};
use crate::json_envelope::{
usage_error, Command as JsonCommand, Envelope, EnvelopeError, PatchAction, PatchEvent,
Expand Down Expand Up @@ -2173,15 +2173,10 @@ async fn run_scan(
report: &mut report::Run,
) -> i32 {
let mut unchecked = 0usize;
let code = Box::pin(scan_project(
args,
invocation,
explicit,
ahead,
&mut unchecked,
report,
))
.await;
// Built by `boxed`, not by a `Box::pin` here, which would make the
// future of a whole scan a temporary of this frame first.
let code =
boxed(|| scan_project(args, invocation, explicit, ahead, &mut unchecked, report)).await;
if unchecked > 0 && code == 0 {
1
} else {
Expand Down Expand Up @@ -3676,21 +3671,26 @@ async fn scan_project(
if let Some(sweep) = withdrawn_sweep {
sweep.record_into(&mut env);
}
return run_redirect(
&args,
&api_client,
&all_packages_with_patches,
can_access_paid_patches,
&policy,
env,
npm_crawl.as_ref(),
&recorded,
lookup_incomplete,
&mut stage,
prior_discovery,
sweep_references,
prune,
)
// The hosted flow's future embeds the whole hosted engine:
// awaited in line it lay in the poll frame of a scan in every
// mode. `boxed` leaves this frame one pointer.
return boxed(|| {
run_redirect(
&args,
&api_client,
&all_packages_with_patches,
can_access_paid_patches,
&policy,
env,
npm_crawl.as_ref(),
&recorded,
lookup_incomplete,
&mut stage,
prior_discovery,
sweep_references,
prune,
)
})
.await;
}

Expand Down
10 changes: 9 additions & 1 deletion crates/socket-patch-cli/src/ecosystem_dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1536,7 +1536,15 @@ impl JvmScope {

/// Box the future `make` returns, constructing it inside this (non-async)
/// frame so the caller's poll frame only ever holds the pointer.
fn boxed<'a, T, F, Fut>(make: F) -> std::pin::Pin<Box<dyn std::future::Future<Output = T> + 'a>>
///
/// `Box::pin(big(..))` written in an async fn builds the future as a
/// temporary in that fn's poll frame first, and a debug build keeps the
/// room for it. Here the temporary is in a frame that is gone before
/// anything is polled: never inlined, or it would be the caller's again.
#[inline(never)]
pub(crate) fn boxed<'a, T, F, Fut>(
make: F,
) -> std::pin::Pin<Box<dyn std::future::Future<Output = T> + 'a>>
where
F: FnOnce() -> Fut,
Fut: std::future::Future<Output = T> + 'a,
Expand Down
Loading