Skip to content

Commit bf2f62c

Browse files
committed
Add test for const parameter before other generic parameters
1 parent ed51b61 commit bf2f62c

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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: (), T>(_: T) {
5+
//~^ ERROR type parameters must be declared prior to const parameters
6+
//~^^ ERROR const generics in any position are currently unsupported
7+
}
8+
9+
fn bar<const X: (), 'a>(_: &'a ()) {
10+
//~^ ERROR lifetime parameters must be declared prior to const parameters
11+
}
12+
13+
fn main() {}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
2+
--> $DIR/const-param-before-other-params.rs:1:12
3+
|
4+
LL | #![feature(const_generics)]
5+
| ^^^^^^^^^^^^^^
6+
7+
error: type parameters must be declared prior to const parameters
8+
--> $DIR/const-param-before-other-params.rs:4:21
9+
|
10+
LL | fn foo<const X: (), T>(_: T) {
11+
| --------------^- help: reorder the parameters: lifetimes, then types, then consts: `<T, X>`
12+
13+
error: lifetime parameters must be declared prior to const parameters
14+
--> $DIR/const-param-before-other-params.rs:9:21
15+
|
16+
LL | fn bar<const X: (), 'a>(_: &'a ()) {
17+
| --------------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, X>`
18+
19+
error: const generics in any position are currently unsupported
20+
--> $DIR/const-param-before-other-params.rs:4:14
21+
|
22+
LL | fn foo<const X: (), T>(_: T) {
23+
| ^
24+
25+
error: aborting due to 3 previous errors
26+

0 commit comments

Comments
 (0)