Skip to content

Commit a188850

Browse files
committed
Add a test for incorrect numbers of const args
1 parent 16d6ee3 commit a188850

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#![feature(const_generics)]
2+
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
3+
4+
fn foo<const X: usize, const Y: usize>() -> usize {
5+
0
6+
}
7+
8+
fn main() {
9+
foo::<0>(); //~ ERROR wrong number of const arguments: expected 2, found 1
10+
foo::<0, 0, 0>(); //~ ERROR wrong number of const arguments: expected 2, found 3
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
2+
--> $DIR/incorrect-number-of-const-args.rs:1:12
3+
|
4+
LL | #![feature(const_generics)]
5+
| ^^^^^^^^^^^^^^
6+
7+
error[E0107]: wrong number of const arguments: expected 2, found 1
8+
--> $DIR/incorrect-number-of-const-args.rs:9:5
9+
|
10+
LL | foo::<0>();
11+
| ^^^^^^^^ expected 2 const arguments
12+
13+
error[E0107]: wrong number of const arguments: expected 2, found 3
14+
--> $DIR/incorrect-number-of-const-args.rs:10:17
15+
|
16+
LL | foo::<0, 0, 0>();
17+
| ^ unexpected const argument
18+
19+
error: aborting due to 2 previous errors
20+
21+
For more information about this error, try `rustc --explain E0107`.

0 commit comments

Comments
 (0)