about summary refs log tree commit diff
path: root/src/test/ui
diff options
context:
space:
mode:
authorBastian Kauschke <bastian_kauschke@hotmail.de>2020-12-31 10:55:20 +0100
committerBastian Kauschke <bastian_kauschke@hotmail.de>2020-12-31 14:10:49 +0100
commit2aef46b17b3d1e2ddd4b985a6b59853746c04b86 (patch)
tree9d93f0dc7e8999872f16695905671306c67167f9 /src/test/ui
parente2267046859c9ceb932abc983561d53a117089f6 (diff)
downloadrust-2aef46b17b3d1e2ddd4b985a6b59853746c04b86.tar.gz
rust-2aef46b17b3d1e2ddd4b985a6b59853746c04b86.zip
support pattern as const parents in type_of
Diffstat (limited to 'src/test/ui')
-rw-r--r--src/test/ui/const-generics/arg-in-pat-1.rs23
-rw-r--r--src/test/ui/const-generics/arg-in-pat-2.rs10
-rw-r--r--src/test/ui/const-generics/arg-in-pat-3.rs43
3 files changed, 76 insertions, 0 deletions
diff --git a/src/test/ui/const-generics/arg-in-pat-1.rs b/src/test/ui/const-generics/arg-in-pat-1.rs
new file mode 100644
index 00000000000..82555084e41
--- /dev/null
+++ b/src/test/ui/const-generics/arg-in-pat-1.rs
@@ -0,0 +1,23 @@
+// check-pass
+enum ConstGenericEnum<const N: usize> {
+    Foo([i32; N]),
+    Bar,
+}
+
+fn foo<const N: usize>(val: &ConstGenericEnum<N>) {
+    if let ConstGenericEnum::<N>::Foo(field, ..) = val {}
+}
+
+fn bar<const N: usize>(val: &ConstGenericEnum<N>) {
+    match val {
+        ConstGenericEnum::<N>::Foo(field, ..) => (),
+        ConstGenericEnum::<N>::Bar => (),
+    }
+}
+
+fn main() {
+    match ConstGenericEnum::Bar {
+        ConstGenericEnum::<3>::Foo(field, ..) => (),
+        ConstGenericEnum::<3>::Bar => (),
+    }
+}
diff --git a/src/test/ui/const-generics/arg-in-pat-2.rs b/src/test/ui/const-generics/arg-in-pat-2.rs
new file mode 100644
index 00000000000..dc9e722eda8
--- /dev/null
+++ b/src/test/ui/const-generics/arg-in-pat-2.rs
@@ -0,0 +1,10 @@
+// check-pass
+enum Generic<const N: usize> {
+    Variant,
+}
+
+fn main() {
+    match todo!() {
+        Generic::<0usize>::Variant => todo!()
+    }
+}
diff --git a/src/test/ui/const-generics/arg-in-pat-3.rs b/src/test/ui/const-generics/arg-in-pat-3.rs
new file mode 100644
index 00000000000..24626a3b68a
--- /dev/null
+++ b/src/test/ui/const-generics/arg-in-pat-3.rs
@@ -0,0 +1,43 @@
+// check-pass
+struct Foo<const N: usize>;
+
+fn bindingp() {
+    match Foo {
+        mut x @ Foo::<3> => {
+            let ref mut _x @ Foo::<3> = x;
+        }
+    }
+}
+
+struct Bar<const N: usize> {
+    field: Foo<N>,
+}
+
+fn structp() {
+    match todo!() {
+        Bar::<3> {
+            field: Foo::<3>,
+        } => (),
+    }
+}
+
+struct Baz<const N: usize>(Foo<N>);
+
+fn tuplestructp() {
+    match Baz(Foo) {
+        Baz::<3>(Foo::<3>) => (),
+    }
+}
+
+impl<const N: usize> Baz<N> {
+    const ASSOC: usize = 3;
+}
+
+fn pathp() {
+    match 3 {
+        Baz::<3>::ASSOC => (),
+        _ => (),
+    }
+}
+
+fn main() {}