diff --git a/tests/ui/generics/unconstrained-param-enum-projection-issue-159811.rs b/tests/ui/generics/unconstrained-param-enum-projection-issue-159811.rs
new file mode 100644
index 0000000000000..8629f1e0ad860
--- /dev/null
+++ b/tests/ui/generics/unconstrained-param-enum-projection-issue-159811.rs
@@ -0,0 +1,27 @@
+//! Regression test for https://github.com/rust-lang/rust/issues/159811.
+
+trait Child {
+ type Error;
+}
+
+trait Site {
+ type Child<'a>: Child
+ where
+ Self: 'a;
+ type Error;
+}
+
+enum MyError
{
+ Own,
+ Parent(P),
+}
+
+impl<'a, S: Site> From< as Child>::Error> for MyError {
+ //~^ ERROR conflicting implementations of trait
+ //~| ERROR the type parameter `S` is not constrained
+ fn from(_: as Child>::Error) -> Self {
+ Self::Own
+ }
+}
+
+fn main() {}
diff --git a/tests/ui/generics/unconstrained-param-enum-projection-issue-159811.stderr b/tests/ui/generics/unconstrained-param-enum-projection-issue-159811.stderr
new file mode 100644
index 0000000000000..2a4400ce4fae0
--- /dev/null
+++ b/tests/ui/generics/unconstrained-param-enum-projection-issue-159811.stderr
@@ -0,0 +1,28 @@
+error[E0119]: conflicting implementations of trait `From>` for type `MyError<_>`
+ --> $DIR/unconstrained-param-enum-projection-issue-159811.rs:19:1
+ |
+LL | impl<'a, S: Site> From< as Child>::Error> for MyError {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: conflicting implementation in crate `core`:
+ - impl From for T;
+
+error[E0207]: the type parameter `S` is not constrained by the impl trait, self type, or predicates
+ --> $DIR/unconstrained-param-enum-projection-issue-159811.rs:19:10
+ |
+LL | impl<'a, S: Site> From< as Child>::Error> for MyError {
+ | ^ unconstrained type parameter
+ |
+help: use the type parameter `S` in the `MyError` type and use it in the type definition
+ |
+LL ~ enum MyError {
+LL | Own,
+...
+LL |
+LL ~ impl<'a, S: Site> From< as Child>::Error> for MyError {
+ |
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0119, E0207.
+For more information about an error, try `rustc --explain E0119`.