Skip to content

Commit 14a1031

Browse files
committed
add self dependent const param test
1 parent 338a271 commit 14a1031

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,8 @@ pub struct Dependent<const N: usize, const X: [u8; N]>([(); N]);
1010
//~^ ERROR: the type of const parameters must not depend on other generic parameters
1111
//~| ERROR: cycle detected when computing type of `Dependent::X`
1212

13+
pub struct SelfDependent<const N: [u8; N]>;
14+
//~^ ERROR: the type of const parameters must not depend on other generic parameters
15+
//~| ERROR: cycle detected when computing type of `SelfDependent::N`
16+
1317
fn main() {}

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

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ error[E0770]: the type of const parameters must not depend on other generic para
44
LL | pub struct Dependent<const N: usize, const X: [u8; N]>([(); N]);
55
| ^ const parameters must have a concrete type
66

7+
error[E0769]: the type of const parameters must not depend on other generic parameters
8+
--> $DIR/const-param-type-depends-on-const-param.rs:13:40
9+
|
10+
LL | pub struct SelfDependent<const N: [u8; N]>;
11+
| ^ const parameters must have a concrete type
12+
713
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
814
--> $DIR/const-param-type-depends-on-const-param.rs:1:12
915
|
@@ -26,6 +32,19 @@ note: cycle used when computing type of `Dependent`
2632
LL | pub struct Dependent<const N: usize, const X: [u8; N]>([(); N]);
2733
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2834

29-
error: aborting due to 2 previous errors; 1 warning emitted
35+
error[E0391]: cycle detected when computing type of `SelfDependent::N`
36+
--> $DIR/const-param-type-depends-on-const-param.rs:13:32
37+
|
38+
LL | pub struct SelfDependent<const N: [u8; N]>;
39+
| ^
40+
|
41+
= note: ...which again requires computing type of `SelfDependent::N`, completing the cycle
42+
note: cycle used when computing type of `SelfDependent`
43+
--> $DIR/const-param-type-depends-on-const-param.rs:13:1
44+
|
45+
LL | pub struct SelfDependent<const N: [u8; N]>;
46+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
47+
48+
error: aborting due to 4 previous errors; 1 warning emitted
3049

3150
For more information about this error, try `rustc --explain E0391`.

0 commit comments

Comments
 (0)