about summary refs log tree commit diff
path: root/tests/ui/consts/associated_const_generic.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/consts/associated_const_generic.rs')
-rw-r--r--tests/ui/consts/associated_const_generic.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/ui/consts/associated_const_generic.rs b/tests/ui/consts/associated_const_generic.rs
new file mode 100644
index 00000000000..dee376cc17b
--- /dev/null
+++ b/tests/ui/consts/associated_const_generic.rs
@@ -0,0 +1,25 @@
+// check-pass
+
+trait TraitA {
+    const VALUE: usize;
+}
+
+struct A;
+impl TraitA for A {
+    const VALUE: usize = 1;
+}
+
+trait TraitB {
+    type MyA: TraitA;
+    const VALUE: usize = Self::MyA::VALUE;
+}
+
+struct B;
+impl TraitB for B {
+    type MyA = A;
+}
+
+fn main() {
+    let _ = [0; A::VALUE];
+    let _ = [0; B::VALUE]; // Indirectly refers to `A::VALUE`
+}