Skip to content

Commit 9702348

Browse files
committed
Clarify that repeat count must be positive
1 parent 3173151 commit 9702348

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

compiler/rustc_builtin_macros/src/concat_bytes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ pub fn expand_concat_bytes(
154154
}
155155
}
156156
} else {
157-
cx.span_err(count.value.span, "repeat count is not a number");
157+
cx.span_err(count.value.span, "repeat count is not a positive number");
158158
}
159159
}
160160
ast::ExprKind::Lit(ref lit) => match lit.kind {

src/test/ui/macros/concat-bytes-error.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ fn main() {
3939
]);
4040
concat_bytes!(5u16); //~ ERROR cannot concatenate numeric literals
4141
concat_bytes!([5u16]); //~ ERROR numeric literal is not a `u8`
42-
concat_bytes!([3; ()]); //~ ERROR repeat count is not a number
43-
concat_bytes!([3; -2]); //~ ERROR repeat count is not a number
44-
concat_bytes!([pie; -2]); //~ ERROR repeat count is not a number
42+
concat_bytes!([3; ()]); //~ ERROR repeat count is not a positive number
43+
concat_bytes!([3; -2]); //~ ERROR repeat count is not a positive number
44+
concat_bytes!([pie; -2]); //~ ERROR repeat count is not a positive number
4545
concat_bytes!([pie; 2]); //~ ERROR expected a byte literal
4646
concat_bytes!([2.2; 0]); //~ ERROR cannot concatenate float literals
47-
concat_bytes!([5.5; ()]); //~ ERROR repeat count is not a number
47+
concat_bytes!([5.5; ()]); //~ ERROR repeat count is not a positive number
4848
concat_bytes!([[1, 2, 3]; 3]); //~ ERROR cannot concatenate doubly nested array
4949
concat_bytes!([[42; 2]; 3]); //~ ERROR cannot concatenate doubly nested array
5050
}

src/test/ui/macros/concat-bytes-error.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -127,19 +127,19 @@ error: numeric literal is not a `u8`
127127
LL | concat_bytes!([5u16]);
128128
| ^^^^
129129

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

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

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

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

0 commit comments

Comments
 (0)