Skip to content

Commit 1b933a5

Browse files
committed
Add a test forbidding the use of const parameters in inner items
1 parent 4e0e188 commit 1b933a5

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-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: u32>() {
5+
//~^ ERROR const generics in any position are currently unsupported
6+
fn bar() -> u32 {
7+
X //~ ERROR can't use generic parameters from outer function
8+
}
9+
}
10+
11+
fn main() {}
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-from-outer-fn.rs:1:12
3+
|
4+
LL | #![feature(const_generics)]
5+
| ^^^^^^^^^^^^^^
6+
7+
error[E0401]: can't use generic parameters from outer function
8+
--> $DIR/const-param-from-outer-fn.rs:7:9
9+
|
10+
LL | fn foo<const X: u32>() {
11+
| - const variable from outer function
12+
LL | //~^ ERROR const generics in any position are currently unsupported
13+
LL | fn bar() -> u32 {
14+
| --- try adding a local generic parameter in this method instead
15+
LL | X //~ ERROR can't use generic parameters from outer function
16+
| ^ use of generic parameter from outer function
17+
18+
error: const generics in any position are currently unsupported
19+
--> $DIR/const-param-from-outer-fn.rs:4:14
20+
|
21+
LL | fn foo<const X: u32>() {
22+
| ^
23+
24+
error: aborting due to 2 previous errors
25+
26+
For more information about this error, try `rustc --explain E0401`.

0 commit comments

Comments
 (0)