add self dependent const param test

This commit is contained in:
Bastian Kauschke 2020-07-08 22:25:22 +02:00
parent 338a27174a
commit 14a1031ec6
2 changed files with 24 additions and 1 deletions

View file

@ -10,4 +10,8 @@ pub struct Dependent<const N: usize, const X: [u8; N]>([(); N]);
//~^ ERROR: the type of const parameters must not depend on other generic parameters
//~| ERROR: cycle detected when computing type of `Dependent::X`
pub struct SelfDependent<const N: [u8; N]>;
//~^ ERROR: the type of const parameters must not depend on other generic parameters
//~| ERROR: cycle detected when computing type of `SelfDependent::N`
fn main() {}

View file

@ -4,6 +4,12 @@ error[E0770]: the type of const parameters must not depend on other generic para
LL | pub struct Dependent<const N: usize, const X: [u8; N]>([(); N]);
| ^ const parameters must have a concrete type
error[E0769]: the type of const parameters must not depend on other generic parameters
--> $DIR/const-param-type-depends-on-const-param.rs:13:40
|
LL | pub struct SelfDependent<const N: [u8; N]>;
| ^ const parameters must have a concrete type
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/const-param-type-depends-on-const-param.rs:1:12
|
@ -26,6 +32,19 @@ note: cycle used when computing type of `Dependent`
LL | pub struct Dependent<const N: usize, const X: [u8; N]>([(); N]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors; 1 warning emitted
error[E0391]: cycle detected when computing type of `SelfDependent::N`
--> $DIR/const-param-type-depends-on-const-param.rs:13:32
|
LL | pub struct SelfDependent<const N: [u8; N]>;
| ^
|
= note: ...which again requires computing type of `SelfDependent::N`, completing the cycle
note: cycle used when computing type of `SelfDependent`
--> $DIR/const-param-type-depends-on-const-param.rs:13:1
|
LL | pub struct SelfDependent<const N: [u8; N]>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 4 previous errors; 1 warning emitted
For more information about this error, try `rustc --explain E0391`.