about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYuki Okushi <jtitor@2k36.org>2021-10-13 21:55:10 +0900
committerGitHub <noreply@github.com>2021-10-13 21:55:10 +0900
commit0caa6164a3ca89f72679d75404abec488a48a2a9 (patch)
tree736b47abcf0240f4b2c5831b0db100c3ae23ca6c
parenta16f686e4a0ea15dcd3b5aa3db7b1cba27bb9453 (diff)
parent0767ed31f3860a7703a4a306f2f266279a55c3dc (diff)
downloadrust-0caa6164a3ca89f72679d75404abec488a48a2a9.tar.gz
rust-0caa6164a3ca89f72679d75404abec488a48a2a9.zip
Rollup merge of #89768 - hellow554:tests, r=Mark-Simulacrum
add some more testcases

resolves #52893
resolves #68295
resolves #87750
resolves #88071

All these issues have been fixed according to glacier. Just adding a test so it can be closed.

Can anybody tell me why the github keywords do not work? 🤔
Please edit this post if you can fix it.
-rw-r--r--src/test/ui/consts/issue-88071.rs21
-rw-r--r--src/test/ui/generic-associated-types/issue-87750.rs22
-rw-r--r--src/test/ui/generic-associated-types/issue-87750.stderr9
-rw-r--r--src/test/ui/traits/issue-52893.rs57
-rw-r--r--src/test/ui/traits/issue-52893.stderr15
-rw-r--r--src/test/ui/traits/issue-68295.rs47
-rw-r--r--src/test/ui/traits/issue-68295.stderr17
7 files changed, 188 insertions, 0 deletions
diff --git a/src/test/ui/consts/issue-88071.rs b/src/test/ui/consts/issue-88071.rs
new file mode 100644
index 00000000000..a2d4a642128
--- /dev/null
+++ b/src/test/ui/consts/issue-88071.rs
@@ -0,0 +1,21 @@
+// check-pass
+//
+// regression test for #88071
+
+#![feature(const_btree_new)]
+#![feature(const_fn_trait_bound)]
+
+use std::collections::BTreeMap;
+
+pub struct CustomMap<K, V>(BTreeMap<K, V>);
+
+impl<K, V> CustomMap<K, V>
+where
+    K: Ord,
+{
+    pub const fn new() -> Self {
+        CustomMap(BTreeMap::new())
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/generic-associated-types/issue-87750.rs b/src/test/ui/generic-associated-types/issue-87750.rs
new file mode 100644
index 00000000000..89bd79ac299
--- /dev/null
+++ b/src/test/ui/generic-associated-types/issue-87750.rs
@@ -0,0 +1,22 @@
+#![feature(generic_associated_types)]
+
+trait PointerFamily {
+    type Pointer<T>;
+}
+
+struct Rc<T>(Box<T>);
+struct RcFamily;
+
+impl PointerFamily for RcFamily {
+    type Pointer<T> = Rc<T>;
+}
+
+#[allow(dead_code)]
+enum Node<T, P: PointerFamily> where P::Pointer<Node<T, P>>: Sized {
+    Cons(P::Pointer<Node<T, P>>),
+}
+
+fn main() {
+    let _list: <RcFamily as PointerFamily>::Pointer<Node<i32, RcFamily>>;
+    //~^ ERROR overflow evaluating the requirement `Node<i32, RcFamily>: Sized`
+}
diff --git a/src/test/ui/generic-associated-types/issue-87750.stderr b/src/test/ui/generic-associated-types/issue-87750.stderr
new file mode 100644
index 00000000000..854541f3d8f
--- /dev/null
+++ b/src/test/ui/generic-associated-types/issue-87750.stderr
@@ -0,0 +1,9 @@
+error[E0275]: overflow evaluating the requirement `Node<i32, RcFamily>: Sized`
+  --> $DIR/issue-87750.rs:20:16
+   |
+LL |     let _list: <RcFamily as PointerFamily>::Pointer<Node<i32, RcFamily>>;
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0275`.
diff --git a/src/test/ui/traits/issue-52893.rs b/src/test/ui/traits/issue-52893.rs
new file mode 100644
index 00000000000..d72598d5d59
--- /dev/null
+++ b/src/test/ui/traits/issue-52893.rs
@@ -0,0 +1,57 @@
+// check-fail
+//
+// regression test for issue 52893
+trait At<Name> {
+    type AtRes;
+    fn at(self) -> Self::AtRes;
+}
+
+trait Push<T> {
+    type PushRes;
+    fn push(self, other: T) -> Self::PushRes;
+}
+
+trait AddClass<Name, F> {
+    type AddRes;
+    fn init(self, func: F);
+}
+
+trait ToRef {
+    type RefRes;
+    fn to_ref(&self) -> Self::RefRes;
+}
+
+struct Class<P>(P);
+
+impl<P> Class<P> {
+    fn with<Name, F>(self) -> <Self as AddClass<Name, F>>::AddRes
+    where
+        Self: AddClass<Name, F>,
+    {
+        todo!()
+    }
+
+    fn from<F>(self) -> <Self as AddClass<P, F>>::AddRes
+    where
+        Self: AddClass<P, F>,
+    {
+        todo!()
+    }
+}
+
+impl<F, Name, P> AddClass<Name, F> for Class<P>
+where
+    Self: At<Name>,
+    <Self as At<Name>>::AtRes: Push<F>,
+    <<Self as At<Name>>::AtRes as Push<F>>::PushRes: ToRef<RefRes = Self> + Push<F>,
+{
+    type AddRes = ();
+
+    fn init(self, func: F) {
+        let builder = self.at().push(func);
+        let output = builder.to_ref();
+        builder.push(output); //~ ERROR mismatched types [E0308]
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/traits/issue-52893.stderr b/src/test/ui/traits/issue-52893.stderr
new file mode 100644
index 00000000000..bf732e24915
--- /dev/null
+++ b/src/test/ui/traits/issue-52893.stderr
@@ -0,0 +1,15 @@
+error[E0308]: mismatched types
+  --> $DIR/issue-52893.rs:53:22
+   |
+LL | impl<F, Name, P> AddClass<Name, F> for Class<P>
+   |      - this type parameter
+...
+LL |         builder.push(output);
+   |                      ^^^^^^ expected type parameter `F`, found struct `Class`
+   |
+   = note: expected type parameter `F`
+                      found struct `Class<P>`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/traits/issue-68295.rs b/src/test/ui/traits/issue-68295.rs
new file mode 100644
index 00000000000..7ff54539adc
--- /dev/null
+++ b/src/test/ui/traits/issue-68295.rs
@@ -0,0 +1,47 @@
+// check-fail
+//
+// regression test for #68295
+
+struct Matrix<R, C, S>(R, C, S);
+
+impl<R, C, S> Matrix<R, C, S> {
+    fn into_owned(self) -> Matrix<R, C, Owned<R, C, ()>>
+    where
+        (): Allocator<R, C>,
+    {
+        unimplemented!()
+    }
+}
+
+impl<D, S> Matrix<D, D, S> {
+    fn hermitian_part(&self) -> Matrix<D, D, Owned<D, D, ()>>
+    where
+        (): Allocator<D, D>,
+    {
+        unimplemented!()
+    }
+}
+
+trait Allocator<R, C> {
+    type Buffer;
+}
+
+trait Trait<R, C, A> {
+    type Power;
+}
+
+impl<R, C, A: Allocator<R, C>> Trait<R, C, A> for () {
+    type Power = A::Buffer;
+}
+
+type Owned<R, C, G> = <G as Trait<R, C, ()>>::Power;
+
+fn crash<R, C>(input: Matrix<R, C, ()>) -> Matrix<R, C, u32>
+where
+    (): Allocator<R, C>,
+{
+    input.into_owned()
+    //~^ ERROR mismatched types [E0308]
+}
+
+fn main() {}
diff --git a/src/test/ui/traits/issue-68295.stderr b/src/test/ui/traits/issue-68295.stderr
new file mode 100644
index 00000000000..cb6e6e0769c
--- /dev/null
+++ b/src/test/ui/traits/issue-68295.stderr
@@ -0,0 +1,17 @@
+error[E0308]: mismatched types
+  --> $DIR/issue-68295.rs:43:5
+   |
+LL | fn crash<R, C>(input: Matrix<R, C, ()>) -> Matrix<R, C, u32>
+   |                                            ----------------- expected `Matrix<R, C, u32>` because of return type
+...
+LL |     input.into_owned()
+   |     ^^^^^^^^^^^^^^^^^^ expected `u32`, found associated type
+   |
+   = note: expected struct `Matrix<_, _, u32>`
+              found struct `Matrix<_, _, <() as Allocator<R, C>>::Buffer>`
+   = help: consider constraining the associated type `<() as Allocator<R, C>>::Buffer` to `u32`
+   = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.