Skip to content

Commit 6891037

Browse files
committed
fix build for Rust 1.56
1 parent 46a2152 commit 6891037

File tree

1 file changed

+30
-17
lines changed

1 file changed

+30
-17
lines changed

src/future_queue_grouped.rs

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,16 @@ where
166166

167167
match ready!(this.in_progress_queue.poll_next_unpin(cx)) {
168168
Some((weight, id, output)) => {
169-
*this.current_global_weight = this.current_global_weight.checked_sub(weight).unwrap_or_else(|| {
170-
panic!(
171-
"future_queue_grouped: subtracted weight {weight} from current {}, overflowed",
169+
*this.current_global_weight = this
170+
.current_global_weight
171+
.checked_sub(weight)
172+
.unwrap_or_else(|| {
173+
panic!(
174+
"future_queue_grouped: subtracted weight {} from current {}, overflowed",
175+
weight,
172176
this.current_global_weight,
173177
)
174-
});
178+
});
175179

176180
let mut any_queued = false;
177181

@@ -183,14 +187,21 @@ where
183187
while data.current_weight < data.max_weight
184188
&& this.current_global_weight < this.max_global_weight
185189
{
186-
let Some((weight, id, future)) = data.queued.pop_front() else { break };
190+
let (weight, id, future) = match data.queued.pop_front() {
191+
Some(x) => x,
192+
None => break,
193+
};
187194
data.add_weight(&id, weight);
188-
*this.current_global_weight = this.current_global_weight.checked_add(weight).unwrap_or_else(|| {
189-
panic!(
190-
"future_queue_grouped: added weight {weight} to current {}, overflowed",
195+
*this.current_global_weight = this
196+
.current_global_weight
197+
.checked_add(weight)
198+
.unwrap_or_else(|| {
199+
panic!(
200+
"future_queue_grouped: added weight {} to current {}, overflowed",
201+
weight,
191202
this.current_global_weight,
192203
)
193-
});
204+
});
194205
this.in_progress_queue
195206
.as_mut()
196207
.get_pin_mut()
@@ -240,7 +251,8 @@ where
240251
data.add_weight(&id, weight);
241252
*this.current_global_weight = this.current_global_weight.checked_add(weight).unwrap_or_else(|| {
242253
panic!(
243-
"future_queue_grouped: added weight {weight} to current {}, overflowed",
254+
"future_queue_grouped: added weight {} to current {}, overflowed",
255+
weight,
244256
this.current_global_weight,
245257
)
246258
});
@@ -276,7 +288,7 @@ where
276288
if any_queued {
277289
// Start any futures that were just queued up. If this returns Pending, then that's fine --
278290
// the task will be scheduled on the waker.
279-
_ = this.in_progress_queue.as_mut().poll_peek(cx);
291+
let _ = this.in_progress_queue.as_mut().poll_peek(cx);
280292
}
281293

282294
if let Some(output) = return_output {
@@ -310,7 +322,7 @@ where
310322
if any_queued {
311323
// It's possible that poll_pop_in_progress might have added more futures to the queue.
312324
let this = self.project();
313-
_ = this.in_progress_queue.poll_peek(cx);
325+
let _ = this.in_progress_queue.poll_peek(cx);
314326
}
315327
Poll::Ready(output)
316328
}
@@ -368,7 +380,8 @@ where
368380
self.group_data.get_mut(id).unwrap()
369381
} else {
370382
panic!(
371-
"unknown semaphore ID: {id:?} (known IDs: {:?})",
383+
"unknown semaphore ID: {:?} (known IDs: {:?})",
384+
id,
372385
self.group_data.keys()
373386
);
374387
}
@@ -391,17 +404,17 @@ impl<Q: fmt::Debug, Fut> GroupData<Q, Fut> {
391404
fn add_weight(&mut self, id: &Q, weight: usize) {
392405
self.current_weight = self.current_weight.checked_add(weight).unwrap_or_else(|| {
393406
panic!(
394-
"future_queue_grouped: for id `{id:?}`, added weight {weight} to current {}, overflowed",
395-
self.current_weight,
407+
"future_queue_grouped: for id `{:?}`, added weight {} to current {}, overflowed",
408+
id, weight, self.current_weight,
396409
)
397410
});
398411
}
399412

400413
fn sub_weight(&mut self, id: &Q, weight: usize) {
401414
self.current_weight = self.current_weight.checked_sub(weight).unwrap_or_else(|| {
402415
panic!(
403-
"future_queue_grouped: for id `{id:?}`, subtracted weight {weight} from current {}, underflowed",
404-
self.current_weight,
416+
"future_queue_grouped: for id `{:?}`, sub weight {} from current {}, underflowed",
417+
id, weight, self.current_weight,
405418
)
406419
});
407420
}

0 commit comments

Comments
 (0)