about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2020-03-29 21:23:52 +0200
committerGitHub <noreply@github.com>2020-03-29 21:23:52 +0200
commit5a7b377b6f71f75c9b3201d7af735b74aa8adf27 (patch)
treea339783b6360b4e3b7dd28e21082d71d340ee8e9
parentd009ce441f59f6a65111d94bb822a1c28872006a (diff)
parent61d419314f3ea5c8e7d3380afc019db1070c4744 (diff)
Rollup merge of #70539 - DutchGhost:test-62220, r=Dylan-DPC
add test for 62220

Closes #62220

Adds a test for https://github.com/rust-lang/rust/issues/62220.

Im not sure whether `check-pass` is sufficient here. I didn't put `run-pass` in, as I'm afraid that'll fail due to the `unimplemented!()` return in the code.
-rw-r--r--src/test/ui/const-generics/issues/issue-62220.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/test/ui/const-generics/issues/issue-62220.rs b/src/test/ui/const-generics/issues/issue-62220.rs
new file mode 100644
index 00000000000..c95b3063201
--- /dev/null
+++ b/src/test/ui/const-generics/issues/issue-62220.rs
@@ -0,0 +1,22 @@
+// build-pass
+#![allow(incomplete_features)]
+
+#![feature(const_generics)]
+pub struct Vector<T, const N: usize>([T; N]);
+
+pub type TruncatedVector<T, const N: usize> = Vector<T, { N - 1 }>;
+
+impl<T, const N: usize> Vector<T, { N }> {
+    /// Drop the last component and return the vector with one fewer dimension.
+    pub fn trunc(self) -> (TruncatedVector<T, { N }>, T) {
+        unimplemented!()
+    }
+}
+
+fn vec4<T>(a: T, b: T, c: T, d: T) -> Vector<T, 4> {
+    Vector([a, b, c, d])
+}
+
+fn main() {
+    let (_xyz, _w): (TruncatedVector<u32, 4>, u32) = vec4(0u32, 1, 2, 3).trunc();
+}