Skip to content

Commit 2f73245

Browse files
committed
Add test forbidding const parameters in const fn
1 parent 455d659 commit 2f73245

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#![feature(const_generics)]
2+
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
3+
4+
const fn const_u32_identity<const X: u32>() -> u32 {
5+
//~^ ERROR const parameters are not permitted in `const fn`
6+
//~^^ ERROR const generics in any position are currently unsupported
7+
X
8+
}
9+
10+
fn main() {
11+
println!("{:?}", const_u32_identity::<18>());
12+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
2+
--> $DIR/const-fn-with-const-param.rs:1:12
3+
|
4+
LL | #![feature(const_generics)]
5+
| ^^^^^^^^^^^^^^
6+
7+
error: const parameters are not permitted in `const fn`
8+
--> $DIR/const-fn-with-const-param.rs:4:1
9+
|
10+
LL | / const fn const_u32_identity<const X: u32>() -> u32 {
11+
LL | | //~^ ERROR const parameters are not permitted in `const fn`
12+
LL | | //~^^ ERROR const generics in any position are currently unsupported
13+
LL | | X
14+
LL | | }
15+
| |_^
16+
17+
error: const generics in any position are currently unsupported
18+
--> $DIR/const-fn-with-const-param.rs:4:35
19+
|
20+
LL | const fn const_u32_identity<const X: u32>() -> u32 {
21+
| ^
22+
23+
error: aborting due to 2 previous errors
24+

0 commit comments

Comments
 (0)