Skip to content
Closed
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
23 changes: 11 additions & 12 deletions src/cargo/core/compiler/job_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,10 +402,8 @@ impl<'cfg> JobQueue<'cfg> {
.map(move |srv| srv.start(move |msg| messages.push(Message::FixDiagnostic(msg))));

crossbeam_utils::thread::scope(move |scope| {
match state.drain_the_queue(cx, plan, scope, &helper) {
Some(err) => Err(err),
None => Ok(()),
}
let (result,) = state.drain_the_queue(cx, plan, scope, &helper);
result
})
.expect("child threads shouldn't panic")
}
Expand Down Expand Up @@ -623,15 +621,16 @@ impl<'cfg> DrainState<'cfg> {
/// This is the "main" loop, where Cargo does all work to run the
/// compiler.
///
/// This returns an Option to prevent the use of `?` on `Result` types
/// because it is important for the loop to carefully handle errors.
/// This returns a tuple of `Result` to prevent the use of `?` on
/// `Result` types because it is important for the loop to
/// carefully handle errors.
fn drain_the_queue(
mut self,
cx: &mut Context<'_, '_>,
plan: &mut BuildPlan,
scope: &Scope<'_>,
jobserver_helper: &HelperThread,
) -> Option<anyhow::Error> {
) -> (Result<(), anyhow::Error>,) {
trace!("queue: {:#?}", self.queue);

// Iteratively execute the entire dependency graph. Each turn of the
Expand Down Expand Up @@ -701,7 +700,7 @@ impl<'cfg> DrainState<'cfg> {
if error.is_some() {
crate::display_error(&e, &mut cx.bcx.config.shell());
} else {
return Some(e);
return (Err(e),);
}
}
if cx.bcx.build_config.emit_json() {
Expand All @@ -713,13 +712,13 @@ impl<'cfg> DrainState<'cfg> {
if error.is_some() {
crate::display_error(&e.into(), &mut cx.bcx.config.shell());
} else {
return Some(e.into());
return (Err(e.into()),);
}
}
}

if let Some(e) = error {
Some(e)
(Err(e),)
} else if self.queue.is_empty() && self.pending_queue.is_empty() {
let message = format!(
"{} [{}] target(s) in {}",
Expand All @@ -729,10 +728,10 @@ impl<'cfg> DrainState<'cfg> {
// It doesn't really matter if this fails.
drop(cx.bcx.config.shell().status("Finished", message));
}
None
(Ok(()),)
} else {
debug!("queue: {:#?}", self.queue);
Some(internal("finished with jobs still left in the queue"))
(Err(internal("finished with jobs still left in the queue")),)
}
}

Expand Down