Skip to content

Commit 5ab0be0

Browse files
committed
Merge branch 'master' into 7656-format-placeholder-code-when-generating-a-crate
2 parents 6baf6bc + 9d32b7b commit 5ab0be0

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

src/cargo/core/compiler/context/mod.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -504,14 +504,12 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
504504

505505
// Drain the client fully
506506
for i in 0..tokens {
507-
while let Err(e) = client.acquire_raw() {
508-
anyhow::bail!(
509-
"failed to fully drain {}/{} token from jobserver at startup: {:?}",
510-
i,
511-
tokens,
512-
e,
513-
);
514-
}
507+
client.acquire_raw().chain_err(|| {
508+
format!(
509+
"failed to fully drain {}/{} token from jobserver at startup",
510+
i, tokens,
511+
)
512+
})?;
515513
}
516514

517515
Ok(client)

src/cargo/core/compiler/job_queue.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ pub struct JobQueue<'a, 'cfg> {
9595
/// It is created from JobQueue when we have fully assembled the crate graph
9696
/// (i.e., all package dependencies are known).
9797
struct DrainState<'a, 'cfg> {
98+
// This is the length of the DependencyQueue when starting out
99+
total_units: usize,
100+
98101
queue: DependencyQueue<Unit<'a>, Artifact, Job>,
99102
tx: Sender<Message>,
100103
rx: Receiver<Message>,
@@ -341,6 +344,7 @@ impl<'a, 'cfg> JobQueue<'a, 'cfg> {
341344
let (tx, rx) = channel();
342345
let progress = Progress::with_style("Building", ProgressStyle::Ratio, cx.bcx.config);
343346
let state = DrainState {
347+
total_units: self.queue.len(),
344348
queue: self.queue,
345349
tx,
346350
rx,
@@ -713,7 +717,7 @@ impl<'a, 'cfg> DrainState<'a, 'cfg> {
713717
.collect::<Vec<_>>();
714718
drop(self.progress.tick_now(
715719
self.finished,
716-
self.queue.len(),
720+
self.total_units,
717721
&format!(": {}", active_names.join(", ")),
718722
));
719723
}

src/cargo/util/progress.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ impl<'cfg> State<'cfg> {
224224

225225
impl Format {
226226
fn progress(&self, cur: usize, max: usize) -> Option<String> {
227+
assert!(cur <= max);
227228
// Render the percentage at the far right and then figure how long the
228229
// progress bar is
229230
let pct = (cur as f64) / (max as f64);

0 commit comments

Comments
 (0)