about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2023-03-27 21:48:43 +0000
committerMichael Goulet <michael@errs.io>2023-03-28 17:07:01 +0000
commitef5f773bffdc2fb28bc833fa6132cbdade1dc549 (patch)
tree401cb9b5fccf1c584534478d1ba9971035508c7d /tests
parentbf57e8ada6dc62369d1cee7ab055fb4074bd2d10 (diff)
downloadrust-ef5f773bffdc2fb28bc833fa6132cbdade1dc549.tar.gz
rust-ef5f773bffdc2fb28bc833fa6132cbdade1dc549.zip
Check for overflow in assemble_candidates_after_normalizing_self_ty
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/traits/new-solver/recursive-self-normalization-2.rs19
-rw-r--r--tests/ui/traits/new-solver/recursive-self-normalization-2.stderr9
-rw-r--r--tests/ui/traits/new-solver/recursive-self-normalization.rs15
-rw-r--r--tests/ui/traits/new-solver/recursive-self-normalization.stderr9
4 files changed, 52 insertions, 0 deletions
diff --git a/tests/ui/traits/new-solver/recursive-self-normalization-2.rs b/tests/ui/traits/new-solver/recursive-self-normalization-2.rs
new file mode 100644
index 00000000000..7417d6018a1
--- /dev/null
+++ b/tests/ui/traits/new-solver/recursive-self-normalization-2.rs
@@ -0,0 +1,19 @@
+// compile-flags: -Ztrait-solver=next
+
+trait Foo1 {
+    type Assoc1;
+}
+
+trait Foo2 {
+    type Assoc2;
+}
+
+trait Bar {}
+fn needs_bar<S: Bar>() {}
+
+fn test<T: Foo1<Assoc1 = <T as Foo2>::Assoc2> + Foo2<Assoc2 = <T as Foo1>::Assoc1>>() {
+    needs_bar::<T::Assoc1>();
+    //~^ ERROR type annotations needed
+}
+
+fn main() {}
diff --git a/tests/ui/traits/new-solver/recursive-self-normalization-2.stderr b/tests/ui/traits/new-solver/recursive-self-normalization-2.stderr
new file mode 100644
index 00000000000..29cfa47a105
--- /dev/null
+++ b/tests/ui/traits/new-solver/recursive-self-normalization-2.stderr
@@ -0,0 +1,9 @@
+error[E0282]: type annotations needed
+  --> $DIR/recursive-self-normalization-2.rs:15:5
+   |
+LL |     needs_bar::<T::Assoc1>();
+   |     ^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `S` declared on the function `needs_bar`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0282`.
diff --git a/tests/ui/traits/new-solver/recursive-self-normalization.rs b/tests/ui/traits/new-solver/recursive-self-normalization.rs
new file mode 100644
index 00000000000..f3e3d71d813
--- /dev/null
+++ b/tests/ui/traits/new-solver/recursive-self-normalization.rs
@@ -0,0 +1,15 @@
+// compile-flags: -Ztrait-solver=next
+
+trait Foo {
+    type Assoc;
+}
+
+trait Bar {}
+fn needs_bar<S: Bar>() {}
+
+fn test<T: Foo<Assoc = <T as Foo>::Assoc>>() {
+    needs_bar::<T::Assoc>();
+    //~^ ERROR type annotations needed
+}
+
+fn main() {}
diff --git a/tests/ui/traits/new-solver/recursive-self-normalization.stderr b/tests/ui/traits/new-solver/recursive-self-normalization.stderr
new file mode 100644
index 00000000000..ba39981893d
--- /dev/null
+++ b/tests/ui/traits/new-solver/recursive-self-normalization.stderr
@@ -0,0 +1,9 @@
+error[E0282]: type annotations needed
+  --> $DIR/recursive-self-normalization.rs:11:5
+   |
+LL |     needs_bar::<T::Assoc>();
+   |     ^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `S` declared on the function `needs_bar`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0282`.