Skip to content

Commit 908a639

Browse files
committed
Add a test for const parameters with type parameters as types
1 parent 102f7a8 commit 908a639

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#![feature(const_generics)]
2+
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
3+
4+
pub struct Dependent<T, const X: T>([(); X]); //~ ERROR const parameters
5+
//~^ ERROR parameter `T` is never used
6+
7+
fn main() {}
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-param-type-depends-on-type-param.rs:1:12
3+
|
4+
LL | #![feature(const_generics)]
5+
| ^^^^^^^^^^^^^^
6+
7+
error[E0671]: const parameters cannot depend on type parameters
8+
--> $DIR/const-param-type-depends-on-type-param.rs:4:34
9+
|
10+
LL | pub struct Dependent<T, const X: T>([(); X]);
11+
| ^ const parameter depends on type parameter
12+
13+
error[E0392]: parameter `T` is never used
14+
--> $DIR/const-param-type-depends-on-type-param.rs:4:22
15+
|
16+
LL | pub struct Dependent<T, const X: T>([(); X]);
17+
| ^ unused parameter
18+
|
19+
= help: consider removing `T` or using a marker such as `std::marker::PhantomData`
20+
21+
error: aborting due to 2 previous errors
22+
23+
Some errors have detailed explanations: E0392, E0671.
24+
For more information about an error, try `rustc --explain E0392`.

0 commit comments

Comments
 (0)