Skip to content

Commit 6d7c794

Browse files
committed
Add comment explaining restriction
1 parent 8f78736 commit 6d7c794

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
#![feature(const_generics)]
22
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
33

4-
pub struct Dependent<T, const X: T>([(); X]); //~ ERROR const parameters
5-
//~^ ERROR parameter `T` is never used
4+
// Currently, const parameters cannot depend on type parameters, because there is no way to
5+
// enforce the `structural_match` property on an arbitrary type parameter. This restriction
6+
// may be relaxed in the future. See https://github.com/rust-lang/rfcs/pull/2000 for more
7+
// details.
8+
9+
pub struct Dependent<T, const X: T>([(); X]);
10+
//~^ ERROR const parameters cannot depend on type parameters
11+
//~^^ ERROR parameter `T` is never used
612

713
fn main() {}

src/test/ui/const-generics/const-param-type-depends-on-type-param.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ LL | #![feature(const_generics)]
55
| ^^^^^^^^^^^^^^
66

77
error[E0671]: const parameters cannot depend on type parameters
8-
--> $DIR/const-param-type-depends-on-type-param.rs:4:34
8+
--> $DIR/const-param-type-depends-on-type-param.rs:9:34
99
|
1010
LL | pub struct Dependent<T, const X: T>([(); X]);
1111
| ^ const parameter depends on type parameter
1212

1313
error[E0392]: parameter `T` is never used
14-
--> $DIR/const-param-type-depends-on-type-param.rs:4:22
14+
--> $DIR/const-param-type-depends-on-type-param.rs:9:22
1515
|
1616
LL | pub struct Dependent<T, const X: T>([(); X]);
1717
| ^ unused parameter

0 commit comments

Comments
 (0)