Skip to content

Commit

Permalink
Clarify that repeat count must be positive
Browse files Browse the repository at this point in the history
  • Loading branch information
syvb committed Dec 27, 2021
1 parent 3173151 commit 9702348
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/concat_bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ pub fn expand_concat_bytes(
}
}
} else {
cx.span_err(count.value.span, "repeat count is not a number");
cx.span_err(count.value.span, "repeat count is not a positive number");
}
}
ast::ExprKind::Lit(ref lit) => match lit.kind {
Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/macros/concat-bytes-error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ fn main() {
]);
concat_bytes!(5u16); //~ ERROR cannot concatenate numeric literals
concat_bytes!([5u16]); //~ ERROR numeric literal is not a `u8`
concat_bytes!([3; ()]); //~ ERROR repeat count is not a number
concat_bytes!([3; -2]); //~ ERROR repeat count is not a number
concat_bytes!([pie; -2]); //~ ERROR repeat count is not a number
concat_bytes!([3; ()]); //~ ERROR repeat count is not a positive number
concat_bytes!([3; -2]); //~ ERROR repeat count is not a positive number
concat_bytes!([pie; -2]); //~ ERROR repeat count is not a positive number
concat_bytes!([pie; 2]); //~ ERROR expected a byte literal
concat_bytes!([2.2; 0]); //~ ERROR cannot concatenate float literals
concat_bytes!([5.5; ()]); //~ ERROR repeat count is not a number
concat_bytes!([5.5; ()]); //~ ERROR repeat count is not a positive number
concat_bytes!([[1, 2, 3]; 3]); //~ ERROR cannot concatenate doubly nested array
concat_bytes!([[42; 2]; 3]); //~ ERROR cannot concatenate doubly nested array
}
8 changes: 4 additions & 4 deletions src/test/ui/macros/concat-bytes-error.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -127,19 +127,19 @@ error: numeric literal is not a `u8`
LL | concat_bytes!([5u16]);
| ^^^^

error: repeat count is not a number
error: repeat count is not a positive number
--> $DIR/concat-bytes-error.rs:42:23
|
LL | concat_bytes!([3; ()]);
| ^^

error: repeat count is not a number
error: repeat count is not a positive number
--> $DIR/concat-bytes-error.rs:43:23
|
LL | concat_bytes!([3; -2]);
| ^^

error: repeat count is not a number
error: repeat count is not a positive number
--> $DIR/concat-bytes-error.rs:44:25
|
LL | concat_bytes!([pie; -2]);
Expand All @@ -159,7 +159,7 @@ error: cannot concatenate float literals
LL | concat_bytes!([2.2; 0]);
| ^^^

error: repeat count is not a number
error: repeat count is not a positive number
--> $DIR/concat-bytes-error.rs:47:25
|
LL | concat_bytes!([5.5; ()]);
Expand Down

0 comments on commit 9702348

Please sign in to comment.