Skip to content

Commit

Permalink
poll_loop!: Improve diagnostics for limit expr
Browse files Browse the repository at this point in the history
Put the $yield_after parameter into an expression context expecting
an integer, so that use of a wrong type of value would get an
error message that's informative and does not mention a variable
internal to the expansion.
  • Loading branch information
mzabaluev committed Nov 7, 2019
1 parent 14b9984 commit e8e2fc4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions futures-core/src/task/poll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ macro_rules! ready {
macro_rules! poll_loop {
{$yield_after:expr, $cx:expr, $body:expr} => {
{
let limit = $yield_after;
let range = 0..$yield_after;
debug_assert!(
limit != 0,
range.end != 0,
"0 used as the repetition limit in a poll loop",
);
for _ in 0..limit {
for _ in range {
$body
}

Expand Down

0 comments on commit e8e2fc4

Please sign in to comment.