about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBastian Kauschke <bastian_kauschke@hotmail.de>2020-07-08 22:25:22 +0200
committerBastian Kauschke <bastian_kauschke@hotmail.de>2020-07-16 11:13:05 +0200
commit14a1031ec6cc4c8a0475e92a4c6ddcd75108e0ee (patch)
treed9024d4a6bc12cb4f27c404a2d91f535ff46e812
parent338a27174a0bd900e573b2ee0e7383244a8b0bf9 (diff)
downloadrust-14a1031ec6cc4c8a0475e92a4c6ddcd75108e0ee.tar.gz
rust-14a1031ec6cc4c8a0475e92a4c6ddcd75108e0ee.zip
add self dependent const param test
-rw-r--r--src/test/ui/const-generics/const-param-type-depends-on-const-param.rs4
-rw-r--r--src/test/ui/const-generics/const-param-type-depends-on-const-param.stderr21
2 files changed, 24 insertions, 1 deletions
diff --git a/src/test/ui/const-generics/const-param-type-depends-on-const-param.rs b/src/test/ui/const-generics/const-param-type-depends-on-const-param.rs
index 6eb13c38e02..9aae73ca4b0 100644
--- a/src/test/ui/const-generics/const-param-type-depends-on-const-param.rs
+++ b/src/test/ui/const-generics/const-param-type-depends-on-const-param.rs
@@ -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() {}
diff --git a/src/test/ui/const-generics/const-param-type-depends-on-const-param.stderr b/src/test/ui/const-generics/const-param-type-depends-on-const-param.stderr
index 63416732bf4..22e55975dcd 100644
--- a/src/test/ui/const-generics/const-param-type-depends-on-const-param.stderr
+++ b/src/test/ui/const-generics/const-param-type-depends-on-const-param.stderr
@@ -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`.