1
Fork 0

Clarify that repeat count must be positive

This commit is contained in:
Smitty 2021-12-27 12:31:40 -05:00
parent 31731511c0
commit 9702348957
3 changed files with 9 additions and 9 deletions

View file

@ -154,7 +154,7 @@ pub fn expand_concat_bytes(
} }
} }
} else { } 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 { ast::ExprKind::Lit(ref lit) => match lit.kind {

View file

@ -39,12 +39,12 @@ fn main() {
]); ]);
concat_bytes!(5u16); //~ ERROR cannot concatenate numeric literals concat_bytes!(5u16); //~ ERROR cannot concatenate numeric literals
concat_bytes!([5u16]); //~ ERROR numeric literal is not a `u8` concat_bytes!([5u16]); //~ ERROR numeric literal is not a `u8`
concat_bytes!([3; ()]); //~ 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 number concat_bytes!([3; -2]); //~ ERROR repeat count is not a positive number
concat_bytes!([pie; -2]); //~ ERROR repeat count is not a number concat_bytes!([pie; -2]); //~ ERROR repeat count is not a positive number
concat_bytes!([pie; 2]); //~ ERROR expected a byte literal concat_bytes!([pie; 2]); //~ ERROR expected a byte literal
concat_bytes!([2.2; 0]); //~ ERROR cannot concatenate float literals 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!([[1, 2, 3]; 3]); //~ ERROR cannot concatenate doubly nested array
concat_bytes!([[42; 2]; 3]); //~ ERROR cannot concatenate doubly nested array concat_bytes!([[42; 2]; 3]); //~ ERROR cannot concatenate doubly nested array
} }

View file

@ -127,19 +127,19 @@ error: numeric literal is not a `u8`
LL | concat_bytes!([5u16]); 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 --> $DIR/concat-bytes-error.rs:42:23
| |
LL | concat_bytes!([3; ()]); 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 --> $DIR/concat-bytes-error.rs:43:23
| |
LL | concat_bytes!([3; -2]); 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 --> $DIR/concat-bytes-error.rs:44:25
| |
LL | concat_bytes!([pie; -2]); LL | concat_bytes!([pie; -2]);
@ -159,7 +159,7 @@ error: cannot concatenate float literals
LL | concat_bytes!([2.2; 0]); 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 --> $DIR/concat-bytes-error.rs:47:25
| |
LL | concat_bytes!([5.5; ()]); LL | concat_bytes!([5.5; ()]);