about summary refs log tree commit diff
path: root/src/test/ui
diff options
context:
space:
mode:
authorMatthew Jasper <mjjasper1@gmail.com>2020-05-30 17:19:31 +0100
committerMatthew Jasper <mjjasper1@gmail.com>2020-06-20 12:13:21 +0100
commit04e589ced8a48818f93d6daff94a4f85e3b07271 (patch)
tree991687e7cba394c4fe7fba7af612f0def2ef2d5b /src/test/ui
parent29272fc514ab8a05b1c228dd5800102f58999dfb (diff)
downloadrust-04e589ced8a48818f93d6daff94a4f85e3b07271.tar.gz
rust-04e589ced8a48818f93d6daff94a4f85e3b07271.zip
Consider fewer predicates for projection candidates
We now require that projection candidates are applicable with the
idenitity substs of the trait, rather than allowing predicates that are
only applicable for certain substs.
Diffstat (limited to 'src/test/ui')
-rw-r--r--src/test/ui/associated-types/hr-associated-type-bound-1.rs18
-rw-r--r--src/test/ui/associated-types/hr-associated-type-bound-1.stderr19
-rw-r--r--src/test/ui/associated-types/hr-associated-type-bound-2.rs21
-rw-r--r--src/test/ui/associated-types/hr-associated-type-bound-2.stderr13
-rw-r--r--src/test/ui/associated-types/hr-associated-type-bound-object.rs14
-rw-r--r--src/test/ui/associated-types/hr-associated-type-bound-object.stderr19
-rw-r--r--src/test/ui/associated-types/hr-associated-type-bound-param-1.rs20
-rw-r--r--src/test/ui/associated-types/hr-associated-type-bound-param-1.stderr19
-rw-r--r--src/test/ui/associated-types/hr-associated-type-bound-param-2.rs21
-rw-r--r--src/test/ui/associated-types/hr-associated-type-bound-param-2.stderr51
-rw-r--r--src/test/ui/associated-types/hr-associated-type-bound-param-3.rs21
-rw-r--r--src/test/ui/associated-types/hr-associated-type-bound-param-3.stderr19
-rw-r--r--src/test/ui/associated-types/hr-associated-type-bound-param-4.rs19
-rw-r--r--src/test/ui/associated-types/hr-associated-type-bound-param-4.stderr19
-rw-r--r--src/test/ui/associated-types/hr-associated-type-bound-param-5.rs41
-rw-r--r--src/test/ui/associated-types/hr-associated-type-bound-param-5.stderr67
-rw-r--r--src/test/ui/associated-types/hr-associated-type-bound-param-6.rs20
-rw-r--r--src/test/ui/associated-types/hr-associated-type-bound-param-6.stderr36
-rw-r--r--src/test/ui/associated-types/hr-associated-type-projection-1.rs21
-rw-r--r--src/test/ui/associated-types/hr-associated-type-projection-1.stderr30
20 files changed, 508 insertions, 0 deletions
diff --git a/src/test/ui/associated-types/hr-associated-type-bound-1.rs b/src/test/ui/associated-types/hr-associated-type-bound-1.rs
new file mode 100644
index 00000000000..497b86eeab8
--- /dev/null
+++ b/src/test/ui/associated-types/hr-associated-type-bound-1.rs
@@ -0,0 +1,18 @@
+trait X<'a>
+where
+    for<'b> <Self as X<'b>>::U: Clone,
+{
+    type U: ?Sized;
+    fn f(&self, x: &Self::U) {
+        <Self::U>::clone(x);
+    }
+}
+
+impl X<'_> for i32 {
+    type U = str;
+    //~^ ERROR the trait bound `for<'b> <i32 as X<'b>>::U: std::clone::Clone`
+}
+
+fn main() {
+    1i32.f("abc");
+}
diff --git a/src/test/ui/associated-types/hr-associated-type-bound-1.stderr b/src/test/ui/associated-types/hr-associated-type-bound-1.stderr
new file mode 100644
index 00000000000..7ef2faef9c6
--- /dev/null
+++ b/src/test/ui/associated-types/hr-associated-type-bound-1.stderr
@@ -0,0 +1,19 @@
+error[E0277]: the trait bound `for<'b> <i32 as X<'b>>::U: std::clone::Clone` is not satisfied
+  --> $DIR/hr-associated-type-bound-1.rs:12:14
+   |
+LL | trait X<'a>
+   |       - required by a bound in this
+LL | where
+LL |     for<'b> <Self as X<'b>>::U: Clone,
+   |                                 ----- required by this bound in `X`
+...
+LL |     type U = str;
+   |              ^^^ the trait `for<'b> std::clone::Clone` is not implemented for `<i32 as X<'b>>::U`
+   |
+   = help: the following implementations were found:
+             <&T as std::clone::Clone>
+             <&mut T as std::clone::Clone>
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/associated-types/hr-associated-type-bound-2.rs b/src/test/ui/associated-types/hr-associated-type-bound-2.rs
new file mode 100644
index 00000000000..7ff0fede28c
--- /dev/null
+++ b/src/test/ui/associated-types/hr-associated-type-bound-2.rs
@@ -0,0 +1,21 @@
+trait X<'a>
+where
+    for<'b> <Self as X<'b>>::U: Clone,
+{
+    type U: ?Sized;
+    fn f(&self, x: &Self::U) {
+        <Self::U>::clone(x);
+    }
+}
+
+impl X<'_> for u32
+where
+    for<'b> <Self as X<'b>>::U: Clone,
+{
+    type U = str;
+}
+
+fn main() {
+    1u32.f("abc");
+    //~^ ERROR no method named `f` found for type `u32` in the current scope
+}
diff --git a/src/test/ui/associated-types/hr-associated-type-bound-2.stderr b/src/test/ui/associated-types/hr-associated-type-bound-2.stderr
new file mode 100644
index 00000000000..2a364d349d7
--- /dev/null
+++ b/src/test/ui/associated-types/hr-associated-type-bound-2.stderr
@@ -0,0 +1,13 @@
+error[E0599]: no method named `f` found for type `u32` in the current scope
+  --> $DIR/hr-associated-type-bound-2.rs:19:10
+   |
+LL |     1u32.f("abc");
+   |          ^ method not found in `u32`
+   |
+   = note: the method `f` exists but the following trait bounds were not satisfied:
+           `<u32 as X<'b>>::U: std::clone::Clone`
+           which is required by `u32: X`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0599`.
diff --git a/src/test/ui/associated-types/hr-associated-type-bound-object.rs b/src/test/ui/associated-types/hr-associated-type-bound-object.rs
new file mode 100644
index 00000000000..7c64ae38caf
--- /dev/null
+++ b/src/test/ui/associated-types/hr-associated-type-bound-object.rs
@@ -0,0 +1,14 @@
+trait X<'a>
+where
+    for<'b> <Self as X<'b>>::U: Clone,
+{
+    type U: ?Sized;
+}
+fn f<'a, T: X<'a> + ?Sized>(x: &<T as X<'a>>::U) {
+    //~^ ERROR the trait bound `for<'b> <T as X<'b>>::U: std::clone::Clone` is not satisfied
+    <<T as X<'_>>::U>::clone(x);
+}
+
+pub fn main() {
+    f::<dyn X<'_, U = str>>("abc");
+}
diff --git a/src/test/ui/associated-types/hr-associated-type-bound-object.stderr b/src/test/ui/associated-types/hr-associated-type-bound-object.stderr
new file mode 100644
index 00000000000..db966875c70
--- /dev/null
+++ b/src/test/ui/associated-types/hr-associated-type-bound-object.stderr
@@ -0,0 +1,19 @@
+error[E0277]: the trait bound `for<'b> <T as X<'b>>::U: std::clone::Clone` is not satisfied
+  --> $DIR/hr-associated-type-bound-object.rs:7:13
+   |
+LL | trait X<'a>
+   |       - required by a bound in this
+LL | where
+LL |     for<'b> <Self as X<'b>>::U: Clone,
+   |                                 ----- required by this bound in `X`
+...
+LL | fn f<'a, T: X<'a> + ?Sized>(x: &<T as X<'a>>::U) {
+   |             ^^^^^ the trait `for<'b> std::clone::Clone` is not implemented for `<T as X<'b>>::U`
+   |
+   = help: the following implementations were found:
+             <&T as std::clone::Clone>
+             <&mut T as std::clone::Clone>
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/associated-types/hr-associated-type-bound-param-1.rs b/src/test/ui/associated-types/hr-associated-type-bound-param-1.rs
new file mode 100644
index 00000000000..a65f8a8c498
--- /dev/null
+++ b/src/test/ui/associated-types/hr-associated-type-bound-param-1.rs
@@ -0,0 +1,20 @@
+trait Y<'a, T: ?Sized>
+where
+    T: Y<'a, Self>,
+    for<'b> <Self as Y<'b, T>>::V: Clone,
+    for<'b> <T as Y<'b, Self>>::V: Clone,
+{
+    type V: ?Sized;
+    fn g(&self, x: &Self::V) {
+        <Self::V>::clone(x);
+    }
+}
+
+impl<'a> Y<'a, u8> for u8 {
+    type V = str;
+    //~^ ERROR the trait bound `for<'b> <u8 as Y<'b, u8>>::V: std::clone::Clone` is not satisfied
+}
+
+fn main() {
+    1u8.g("abc");
+}
diff --git a/src/test/ui/associated-types/hr-associated-type-bound-param-1.stderr b/src/test/ui/associated-types/hr-associated-type-bound-param-1.stderr
new file mode 100644
index 00000000000..347a5818dce
--- /dev/null
+++ b/src/test/ui/associated-types/hr-associated-type-bound-param-1.stderr
@@ -0,0 +1,19 @@
+error[E0277]: the trait bound `for<'b> <u8 as Y<'b, u8>>::V: std::clone::Clone` is not satisfied
+  --> $DIR/hr-associated-type-bound-param-1.rs:14:14
+   |
+LL | trait Y<'a, T: ?Sized>
+   |       - required by a bound in this
+...
+LL |     for<'b> <Self as Y<'b, T>>::V: Clone,
+   |                                    ----- required by this bound in `Y`
+...
+LL |     type V = str;
+   |              ^^^ the trait `for<'b> std::clone::Clone` is not implemented for `<u8 as Y<'b, u8>>::V`
+   |
+   = help: the following implementations were found:
+             <&T as std::clone::Clone>
+             <&mut T as std::clone::Clone>
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/associated-types/hr-associated-type-bound-param-2.rs b/src/test/ui/associated-types/hr-associated-type-bound-param-2.rs
new file mode 100644
index 00000000000..9f849b03276
--- /dev/null
+++ b/src/test/ui/associated-types/hr-associated-type-bound-param-2.rs
@@ -0,0 +1,21 @@
+trait Z<'a, T: ?Sized>
+where
+    T: Z<'a, u16>,
+    //~^ the trait bound `for<'b> <u16 as Z<'b, u16>>::W: std::clone::Clone` is not satisfied
+    //~| the trait bound `for<'b> <u16 as Z<'b, u16>>::W: std::clone::Clone` is not satisfied
+    for<'b> <T as Z<'b, u16>>::W: Clone,
+{
+    type W: ?Sized;
+    fn h(&self, x: &T::W) {
+        <T::W>::clone(x);
+    }
+}
+
+impl<'a> Z<'a, u16> for u16 {
+    type W = str;
+    //~^ ERROR the trait bound `for<'b> <u16 as Z<'b, u16>>::W: std::clone::Clone
+}
+
+fn main() {
+    1u16.h("abc");
+}
diff --git a/src/test/ui/associated-types/hr-associated-type-bound-param-2.stderr b/src/test/ui/associated-types/hr-associated-type-bound-param-2.stderr
new file mode 100644
index 00000000000..e06777e36a8
--- /dev/null
+++ b/src/test/ui/associated-types/hr-associated-type-bound-param-2.stderr
@@ -0,0 +1,51 @@
+error[E0277]: the trait bound `for<'b> <u16 as Z<'b, u16>>::W: std::clone::Clone` is not satisfied
+  --> $DIR/hr-associated-type-bound-param-2.rs:3:8
+   |
+LL | trait Z<'a, T: ?Sized>
+   |       - required by a bound in this
+LL | where
+LL |     T: Z<'a, u16>,
+   |        ^^^^^^^^^^ the trait `for<'b> std::clone::Clone` is not implemented for `<u16 as Z<'b, u16>>::W`
+...
+LL |     for<'b> <T as Z<'b, u16>>::W: Clone,
+   |                                   ----- required by this bound in `Z`
+   |
+   = help: the following implementations were found:
+             <&T as std::clone::Clone>
+             <&mut T as std::clone::Clone>
+
+error[E0277]: the trait bound `for<'b> <u16 as Z<'b, u16>>::W: std::clone::Clone` is not satisfied
+  --> $DIR/hr-associated-type-bound-param-2.rs:15:14
+   |
+LL | trait Z<'a, T: ?Sized>
+   |       - required by a bound in this
+...
+LL |     for<'b> <T as Z<'b, u16>>::W: Clone,
+   |                                   ----- required by this bound in `Z`
+...
+LL |     type W = str;
+   |              ^^^ the trait `for<'b> std::clone::Clone` is not implemented for `<u16 as Z<'b, u16>>::W`
+   |
+   = help: the following implementations were found:
+             <&T as std::clone::Clone>
+             <&mut T as std::clone::Clone>
+
+error[E0277]: the trait bound `for<'b> <u16 as Z<'b, u16>>::W: std::clone::Clone` is not satisfied
+  --> $DIR/hr-associated-type-bound-param-2.rs:3:8
+   |
+LL | trait Z<'a, T: ?Sized>
+   |       - required by a bound in this
+LL | where
+LL |     T: Z<'a, u16>,
+   |        ^^^^^^^^^^ the trait `for<'b> std::clone::Clone` is not implemented for `<u16 as Z<'b, u16>>::W`
+...
+LL |     for<'b> <T as Z<'b, u16>>::W: Clone,
+   |                                   ----- required by this bound in `Z`
+   |
+   = help: the following implementations were found:
+             <&T as std::clone::Clone>
+             <&mut T as std::clone::Clone>
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/associated-types/hr-associated-type-bound-param-3.rs b/src/test/ui/associated-types/hr-associated-type-bound-param-3.rs
new file mode 100644
index 00000000000..9aca59f8ce6
--- /dev/null
+++ b/src/test/ui/associated-types/hr-associated-type-bound-param-3.rs
@@ -0,0 +1,21 @@
+// ignore-tidy-linelength
+
+trait X<'a, T>
+where
+    for<'b> T: X<'b, T>,
+    for<'b> <T as X<'b, T>>::U: Clone,
+{
+    type U: ?Sized;
+    fn f(x: &<T as X<'_, T>>::U) {
+        <<T as X<'_, T>>::U>::clone(x);
+    }
+}
+
+impl<S, T> X<'_, (T,)> for (S,) {
+    type U = str;
+    //~^ ERROR the trait bound `for<'b> <(T,) as X<'b, (T,)>>::U: std::clone::Clone` is not satisfied
+}
+
+pub fn main() {
+    <(i32,) as X<(i32,)>>::f("abc");
+}
diff --git a/src/test/ui/associated-types/hr-associated-type-bound-param-3.stderr b/src/test/ui/associated-types/hr-associated-type-bound-param-3.stderr
new file mode 100644
index 00000000000..ff56f60e4c9
--- /dev/null
+++ b/src/test/ui/associated-types/hr-associated-type-bound-param-3.stderr
@@ -0,0 +1,19 @@
+error[E0277]: the trait bound `for<'b> <(T,) as X<'b, (T,)>>::U: std::clone::Clone` is not satisfied
+  --> $DIR/hr-associated-type-bound-param-3.rs:15:14
+   |
+LL | trait X<'a, T>
+   |       - required by a bound in this
+...
+LL |     for<'b> <T as X<'b, T>>::U: Clone,
+   |                                 ----- required by this bound in `X`
+...
+LL |     type U = str;
+   |              ^^^ the trait `for<'b> std::clone::Clone` is not implemented for `<(T,) as X<'b, (T,)>>::U`
+   |
+   = help: the following implementations were found:
+             <&T as std::clone::Clone>
+             <&mut T as std::clone::Clone>
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/associated-types/hr-associated-type-bound-param-4.rs b/src/test/ui/associated-types/hr-associated-type-bound-param-4.rs
new file mode 100644
index 00000000000..ffe43c674c3
--- /dev/null
+++ b/src/test/ui/associated-types/hr-associated-type-bound-param-4.rs
@@ -0,0 +1,19 @@
+trait X<'a, T>
+where
+    for<'b> (T,): X<'b, T>,
+    for<'b> <(T,) as X<'b, T>>::U: Clone,
+{
+    type U: ?Sized;
+    fn f(x: &<(T,) as X<'_, T>>::U) {
+        <<(T,) as X<'_, T>>::U>::clone(x);
+    }
+}
+
+impl<S, T> X<'_, T> for (S,) {
+    type U = str;
+    //~^ ERROR the trait bound `for<'b> <(T,) as X<'b, T>>::U: std::clone::Clone` is not satisfied
+}
+
+pub fn main() {
+    <(i32,) as X<i32>>::f("abc");
+}
diff --git a/src/test/ui/associated-types/hr-associated-type-bound-param-4.stderr b/src/test/ui/associated-types/hr-associated-type-bound-param-4.stderr
new file mode 100644
index 00000000000..c41efb8b6e1
--- /dev/null
+++ b/src/test/ui/associated-types/hr-associated-type-bound-param-4.stderr
@@ -0,0 +1,19 @@
+error[E0277]: the trait bound `for<'b> <(T,) as X<'b, T>>::U: std::clone::Clone` is not satisfied
+  --> $DIR/hr-associated-type-bound-param-4.rs:13:14
+   |
+LL | trait X<'a, T>
+   |       - required by a bound in this
+...
+LL |     for<'b> <(T,) as X<'b, T>>::U: Clone,
+   |                                    ----- required by this bound in `X`
+...
+LL |     type U = str;
+   |              ^^^ the trait `for<'b> std::clone::Clone` is not implemented for `<(T,) as X<'b, T>>::U`
+   |
+   = help: the following implementations were found:
+             <&T as std::clone::Clone>
+             <&mut T as std::clone::Clone>
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/associated-types/hr-associated-type-bound-param-5.rs b/src/test/ui/associated-types/hr-associated-type-bound-param-5.rs
new file mode 100644
index 00000000000..dcca0b3ce92
--- /dev/null
+++ b/src/test/ui/associated-types/hr-associated-type-bound-param-5.rs
@@ -0,0 +1,41 @@
+// ignore-tidy-linelength
+
+trait Cycle: Sized {
+    type Next: Cycle<Next = Self>;
+}
+
+impl<T> Cycle for Box<T> {
+    type Next = Vec<T>;
+}
+
+impl<T> Cycle for Vec<T> {
+    type Next = Box<T>;
+}
+
+trait X<'a, T: Cycle + for<'b> X<'b, T>>
+where
+    for<'b> <T as X<'b, T>>::U: Clone,
+    for<'b> T::Next: X<'b, T::Next>,
+    for<'b> <T::Next as X<'b, T::Next>>::U: Clone,
+{
+    type U: ?Sized;
+    fn f(x: &<T as X<'_, T>>::U) {
+        <<T as X<'_, T>>::U>::clone(x);
+    }
+}
+
+impl<S, T> X<'_, Vec<T>> for S {
+    type U = str;
+    //~^ ERROR the trait bound `for<'b> <std::boxed::Box<T> as X<'b, std::boxed::Box<T>>>::U: std::clone::Clone` is not satisfied
+    //~| ERROR the trait bound `for<'b> <std::vec::Vec<T> as X<'b, std::vec::Vec<T>>>::U: std::clone::Clone` is not satisfied
+}
+
+impl<S, T> X<'_, Box<T>> for S {
+    type U = str;
+    //~^ ERROR the trait bound `for<'b> <std::boxed::Box<T> as X<'b, std::boxed::Box<T>>>::U: std::clone::Clone` is not satisfied
+    //~| ERROR the trait bound `for<'b> <std::vec::Vec<T> as X<'b, std::vec::Vec<T>>>::U: std::clone::Clone` is not satisfied
+}
+
+pub fn main() {
+    <i32 as X<Box<i32>>>::f("abc");
+}
diff --git a/src/test/ui/associated-types/hr-associated-type-bound-param-5.stderr b/src/test/ui/associated-types/hr-associated-type-bound-param-5.stderr
new file mode 100644
index 00000000000..39c191e9747
--- /dev/null
+++ b/src/test/ui/associated-types/hr-associated-type-bound-param-5.stderr
@@ -0,0 +1,67 @@
+error[E0277]: the trait bound `for<'b> <std::boxed::Box<T> as X<'b, std::boxed::Box<T>>>::U: std::clone::Clone` is not satisfied
+  --> $DIR/hr-associated-type-bound-param-5.rs:28:14
+   |
+LL | trait X<'a, T: Cycle + for<'b> X<'b, T>>
+   |       - required by a bound in this
+...
+LL |     for<'b> <T::Next as X<'b, T::Next>>::U: Clone,
+   |                                             ----- required by this bound in `X`
+...
+LL |     type U = str;
+   |              ^^^ the trait `for<'b> std::clone::Clone` is not implemented for `<std::boxed::Box<T> as X<'b, std::boxed::Box<T>>>::U`
+   |
+   = help: the following implementations were found:
+             <&T as std::clone::Clone>
+             <&mut T as std::clone::Clone>
+
+error[E0277]: the trait bound `for<'b> <std::vec::Vec<T> as X<'b, std::vec::Vec<T>>>::U: std::clone::Clone` is not satisfied
+  --> $DIR/hr-associated-type-bound-param-5.rs:28:14
+   |
+LL | trait X<'a, T: Cycle + for<'b> X<'b, T>>
+   |       - required by a bound in this
+LL | where
+LL |     for<'b> <T as X<'b, T>>::U: Clone,
+   |                                 ----- required by this bound in `X`
+...
+LL |     type U = str;
+   |              ^^^ the trait `for<'b> std::clone::Clone` is not implemented for `<std::vec::Vec<T> as X<'b, std::vec::Vec<T>>>::U`
+   |
+   = help: the following implementations were found:
+             <&T as std::clone::Clone>
+             <&mut T as std::clone::Clone>
+
+error[E0277]: the trait bound `for<'b> <std::vec::Vec<T> as X<'b, std::vec::Vec<T>>>::U: std::clone::Clone` is not satisfied
+  --> $DIR/hr-associated-type-bound-param-5.rs:34:14
+   |
+LL | trait X<'a, T: Cycle + for<'b> X<'b, T>>
+   |       - required by a bound in this
+...
+LL |     for<'b> <T::Next as X<'b, T::Next>>::U: Clone,
+   |                                             ----- required by this bound in `X`
+...
+LL |     type U = str;
+   |              ^^^ the trait `for<'b> std::clone::Clone` is not implemented for `<std::vec::Vec<T> as X<'b, std::vec::Vec<T>>>::U`
+   |
+   = help: the following implementations were found:
+             <&T as std::clone::Clone>
+             <&mut T as std::clone::Clone>
+
+error[E0277]: the trait bound `for<'b> <std::boxed::Box<T> as X<'b, std::boxed::Box<T>>>::U: std::clone::Clone` is not satisfied
+  --> $DIR/hr-associated-type-bound-param-5.rs:34:14
+   |
+LL | trait X<'a, T: Cycle + for<'b> X<'b, T>>
+   |       - required by a bound in this
+LL | where
+LL |     for<'b> <T as X<'b, T>>::U: Clone,
+   |                                 ----- required by this bound in `X`
+...
+LL |     type U = str;
+   |              ^^^ the trait `for<'b> std::clone::Clone` is not implemented for `<std::boxed::Box<T> as X<'b, std::boxed::Box<T>>>::U`
+   |
+   = help: the following implementations were found:
+             <&T as std::clone::Clone>
+             <&mut T as std::clone::Clone>
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/associated-types/hr-associated-type-bound-param-6.rs b/src/test/ui/associated-types/hr-associated-type-bound-param-6.rs
new file mode 100644
index 00000000000..4b8018cb430
--- /dev/null
+++ b/src/test/ui/associated-types/hr-associated-type-bound-param-6.rs
@@ -0,0 +1,20 @@
+trait X<'a, T>
+where
+    for<'b> T: X<'b, T>,
+    for<'b> <T as X<'b, T>>::U: Clone,
+{
+    type U: ?Sized;
+    fn f(x: &<T as X<'_, T>>::U) {
+        <<T as X<'_, T>>::U>::clone(x);
+    }
+}
+
+impl<S, T> X<'_, T> for (S,) {
+    //~^ ERROR the trait bound `for<'b> T: X<'b, T>` is not satisfied
+    type U = str;
+    //~^ ERROR the trait bound `for<'b> <T as X<'b, T>>::U: std::clone::Clone` is not satisfied
+}
+
+pub fn main() {
+    <(i32,) as X<i32>>::f("abc");
+}
diff --git a/src/test/ui/associated-types/hr-associated-type-bound-param-6.stderr b/src/test/ui/associated-types/hr-associated-type-bound-param-6.stderr
new file mode 100644
index 00000000000..83845d3a941
--- /dev/null
+++ b/src/test/ui/associated-types/hr-associated-type-bound-param-6.stderr
@@ -0,0 +1,36 @@
+error[E0277]: the trait bound `for<'b> <T as X<'b, T>>::U: std::clone::Clone` is not satisfied
+  --> $DIR/hr-associated-type-bound-param-6.rs:14:14
+   |
+LL | trait X<'a, T>
+   |       - required by a bound in this
+...
+LL |     for<'b> <T as X<'b, T>>::U: Clone,
+   |                                 ----- required by this bound in `X`
+...
+LL |     type U = str;
+   |              ^^^ the trait `for<'b> std::clone::Clone` is not implemented for `<T as X<'b, T>>::U`
+   |
+   = help: the following implementations were found:
+             <&T as std::clone::Clone>
+             <&mut T as std::clone::Clone>
+
+error[E0277]: the trait bound `for<'b> T: X<'b, T>` is not satisfied
+  --> $DIR/hr-associated-type-bound-param-6.rs:12:12
+   |
+LL | trait X<'a, T>
+   |       - required by a bound in this
+LL | where
+LL |     for<'b> T: X<'b, T>,
+   |                -------- required by this bound in `X`
+...
+LL | impl<S, T> X<'_, T> for (S,) {
+   |            ^^^^^^^^ the trait `for<'b> X<'b, T>` is not implemented for `T`
+   |
+help: consider restricting type parameter `T`
+   |
+LL | impl<S, T: for<'b> X<'b, T>> X<'_, T> for (S,) {
+   |          ^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/associated-types/hr-associated-type-projection-1.rs b/src/test/ui/associated-types/hr-associated-type-projection-1.rs
new file mode 100644
index 00000000000..0d4567a55fc
--- /dev/null
+++ b/src/test/ui/associated-types/hr-associated-type-projection-1.rs
@@ -0,0 +1,21 @@
+trait UnsafeCopy<'a, T: Copy>
+where
+    for<'b> <Self as UnsafeCopy<'b, T>>::Item: std::ops::Deref<Target = T>,
+{
+    type Item;
+
+    fn bug(item: &Self::Item) -> () {
+        let x: T = **item;
+        &x as *const _;
+    }
+}
+
+impl<T: Copy + std::ops::Deref> UnsafeCopy<'_, T> for T {
+    //~^ ERROR the trait bound `<T as UnsafeCopy<'b, T>>::Item: std::ops::Deref` is not satisfied
+    type Item = T;
+    //~^ ERROR the trait bound `for<'b> <T as UnsafeCopy<'b, T>>::Item: std::ops::Deref
+}
+
+pub fn main() {
+    <&'static str>::bug(&"");
+}
diff --git a/src/test/ui/associated-types/hr-associated-type-projection-1.stderr b/src/test/ui/associated-types/hr-associated-type-projection-1.stderr
new file mode 100644
index 00000000000..5ab57410c44
--- /dev/null
+++ b/src/test/ui/associated-types/hr-associated-type-projection-1.stderr
@@ -0,0 +1,30 @@
+error[E0277]: the trait bound `for<'b> <T as UnsafeCopy<'b, T>>::Item: std::ops::Deref` is not satisfied
+  --> $DIR/hr-associated-type-projection-1.rs:15:17
+   |
+LL | trait UnsafeCopy<'a, T: Copy>
+   |       ---------- required by a bound in this
+LL | where
+LL |     for<'b> <Self as UnsafeCopy<'b, T>>::Item: std::ops::Deref<Target = T>,
+   |                                                --------------------------- required by this bound in `UnsafeCopy`
+...
+LL |     type Item = T;
+   |                 ^ the trait `for<'b> std::ops::Deref` is not implemented for `<T as UnsafeCopy<'b, T>>::Item`
+   |
+   = help: the following implementations were found:
+             <&T as std::ops::Deref>
+             <&mut T as std::ops::Deref>
+
+error[E0277]: the trait bound `<T as UnsafeCopy<'b, T>>::Item: std::ops::Deref` is not satisfied
+  --> $DIR/hr-associated-type-projection-1.rs:13:33
+   |
+LL | impl<T: Copy + std::ops::Deref> UnsafeCopy<'_, T> for T {
+   |                                 ^^^^^^^^^^^^^^^^^ the trait `std::ops::Deref` is not implemented for `<T as UnsafeCopy<'b, T>>::Item`
+   |
+help: consider further restricting the associated type
+   |
+LL | impl<T: Copy + std::ops::Deref> UnsafeCopy<'_, T> for T where <T as UnsafeCopy<'b, T>>::Item: std::ops::Deref {
+   |                                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0277`.