summaryrefslogtreecommitdiffstats
path: root/tests/ui/type-alias-impl-trait
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:35 +0000
commitd1b2d29528b7794b41e66fc2136e395a02f8529b (patch)
treea4a17504b260206dec3cf55b2dca82929a348ac2 /tests/ui/type-alias-impl-trait
parentReleasing progress-linux version 1.72.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.tar.xz
rustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.zip
Merging upstream version 1.73.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/type-alias-impl-trait')
-rw-r--r--tests/ui/type-alias-impl-trait/auto-trait-leakage3.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/broken_mir.rs16
-rw-r--r--tests/ui/type-alias-impl-trait/coherence.rs2
-rw-r--r--tests/ui/type-alias-impl-trait/coherence.stderr8
-rw-r--r--tests/ui/type-alias-impl-trait/coherence_generalization.rs5
-rw-r--r--tests/ui/type-alias-impl-trait/hidden_type_mismatch.rs57
-rw-r--r--tests/ui/type-alias-impl-trait/hidden_type_mismatch.stderr14
-rw-r--r--tests/ui/type-alias-impl-trait/inference-cycle.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/issue-53092-2.stderr1
-rw-r--r--tests/ui/type-alias-impl-trait/issue-96572-unconstrained.rs2
-rw-r--r--tests/ui/type-alias-impl-trait/nested-rpit-with-lifetimes.rs49
-rw-r--r--tests/ui/type-alias-impl-trait/nested-tait-hrtb.rs15
-rw-r--r--tests/ui/type-alias-impl-trait/nested-tait-hrtb.stderr23
-rw-r--r--tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn-2.rs21
-rw-r--r--tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn-2.stderr14
-rw-r--r--tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn.rs34
-rw-r--r--tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn.stderr14
-rw-r--r--tests/ui/type-alias-impl-trait/reveal_local.stderr3
-rw-r--r--tests/ui/type-alias-impl-trait/unconstrained-impl-param.rs25
-rw-r--r--tests/ui/type-alias-impl-trait/unconstrained-impl-param.stderr9
-rw-r--r--tests/ui/type-alias-impl-trait/under-binder.rs9
-rw-r--r--tests/ui/type-alias-impl-trait/under-binder.stderr12
-rw-r--r--tests/ui/type-alias-impl-trait/wf-check-rpit-lifetimes.rs19
23 files changed, 349 insertions, 7 deletions
diff --git a/tests/ui/type-alias-impl-trait/auto-trait-leakage3.stderr b/tests/ui/type-alias-impl-trait/auto-trait-leakage3.stderr
index dd56c59bf..5bd0f76c3 100644
--- a/tests/ui/type-alias-impl-trait/auto-trait-leakage3.stderr
+++ b/tests/ui/type-alias-impl-trait/auto-trait-leakage3.stderr
@@ -16,6 +16,7 @@ note: cycle used when checking item types in module `m`
|
LL | mod m {
| ^^^^^
+ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
error[E0391]: cycle detected when computing type of `m::Foo::{opaque#0}`
--> $DIR/auto-trait-leakage3.rs:7:20
@@ -34,6 +35,7 @@ note: cycle used when checking item types in module `m`
|
LL | mod m {
| ^^^^^
+ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
error: cannot check whether the hidden type of `auto_trait_leakage3[211d]::m::Foo::{opaque#0}` satisfies auto traits
--> $DIR/auto-trait-leakage3.rs:16:17
diff --git a/tests/ui/type-alias-impl-trait/broken_mir.rs b/tests/ui/type-alias-impl-trait/broken_mir.rs
new file mode 100644
index 000000000..b68e798fb
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/broken_mir.rs
@@ -0,0 +1,16 @@
+//! ICE: https://github.com/rust-lang/rust/issues/114121
+//! This test checks that MIR validation never constrains
+//! new hidden types that *differ* from the actual hidden types.
+//! This test used to ICE because oli-obk assumed mir validation
+//! was only ever run after opaque types were revealed in MIR.
+
+// compile-flags: -Zvalidate-mir
+// check-pass
+
+fn main() {
+ let _ = Some(()).into_iter().flat_map(|_| Some(()).into_iter().flat_map(func));
+}
+
+fn func(_: ()) -> impl Iterator<Item = ()> {
+ Some(()).into_iter().flat_map(|_| vec![])
+}
diff --git a/tests/ui/type-alias-impl-trait/coherence.rs b/tests/ui/type-alias-impl-trait/coherence.rs
index 077a31494..1700c800e 100644
--- a/tests/ui/type-alias-impl-trait/coherence.rs
+++ b/tests/ui/type-alias-impl-trait/coherence.rs
@@ -11,7 +11,7 @@ fn use_alias<T>(val: T) -> AliasOfForeignType<T> {
foreign_crate::ForeignType(val)
}
-impl<T> foreign_crate::ForeignTrait for AliasOfForeignType<T> {}
+impl foreign_crate::ForeignTrait for AliasOfForeignType<()> {}
//~^ ERROR only traits defined in the current crate can be implemented for arbitrary types
fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/coherence.stderr b/tests/ui/type-alias-impl-trait/coherence.stderr
index c923eb08a..36bbb985e 100644
--- a/tests/ui/type-alias-impl-trait/coherence.stderr
+++ b/tests/ui/type-alias-impl-trait/coherence.stderr
@@ -1,10 +1,10 @@
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> $DIR/coherence.rs:14:1
|
-LL | impl<T> foreign_crate::ForeignTrait for AliasOfForeignType<T> {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------
- | | |
- | | `AliasOfForeignType<T>` is not defined in the current crate
+LL | impl foreign_crate::ForeignTrait for AliasOfForeignType<()> {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------
+ | | |
+ | | `AliasOfForeignType<()>` is not defined in the current crate
| impl doesn't use only types from inside the current crate
|
= note: define and implement a trait or new type instead
diff --git a/tests/ui/type-alias-impl-trait/coherence_generalization.rs b/tests/ui/type-alias-impl-trait/coherence_generalization.rs
index 679b2b0f1..1ec8877ea 100644
--- a/tests/ui/type-alias-impl-trait/coherence_generalization.rs
+++ b/tests/ui/type-alias-impl-trait/coherence_generalization.rs
@@ -2,6 +2,7 @@
// FIXME(type_alias_impl_trait): What does this test? This needs a comment
// explaining what we're worried about here.
+
#![feature(type_alias_impl_trait)]
trait Trait {}
type Opaque<T> = impl Sized;
@@ -9,7 +10,7 @@ fn foo<T>() -> Opaque<T> {
()
}
-impl<T, V> Trait for (T, V, V, u32) {}
-impl<U, V> Trait for (Opaque<U>, V, i32, V) {}
+impl<T, U, V> Trait for (T, U, V, V, u32) {}
+impl<U, V> Trait for (Opaque<U>, U, V, i32, V) {}
fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/hidden_type_mismatch.rs b/tests/ui/type-alias-impl-trait/hidden_type_mismatch.rs
new file mode 100644
index 000000000..12ce6b14e
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/hidden_type_mismatch.rs
@@ -0,0 +1,57 @@
+//! This test checks that we don't lose hidden types
+//! for *other* opaque types that we register and use
+//! to prove bounds while checking that a hidden type
+//! satisfies its opaque type's bounds.
+
+#![feature(trivial_bounds, type_alias_impl_trait)]
+#![allow(trivial_bounds)]
+
+mod sus {
+ use super::*;
+ pub type Sep = impl Sized + std::fmt::Display;
+ //~^ ERROR: concrete type differs from previous defining opaque type use
+ pub fn mk_sep() -> Sep {
+ String::from("hello")
+ }
+
+ pub trait Proj {
+ type Assoc;
+ }
+ impl Proj for () {
+ type Assoc = sus::Sep;
+ }
+
+ pub struct Bar<T: Proj> {
+ pub inner: <T as Proj>::Assoc,
+ pub _marker: T,
+ }
+ impl<T: Proj> Clone for Bar<T> {
+ fn clone(&self) -> Self {
+ todo!()
+ }
+ }
+ impl<T: Proj<Assoc = i32> + Copy> Copy for Bar<T> {}
+ // This allows producing `Tait`s via `From`, even though
+ // `define_tait` is not actually callable, and thus assumed
+ // `Bar<()>: Copy` even though it isn't.
+ pub type Tait = impl Copy + From<Bar<()>> + Into<Bar<()>>;
+ pub fn define_tait() -> Tait
+ where
+ // this proves `Bar<()>: Copy`, but `define_tait` is
+ // now uncallable
+ (): Proj<Assoc = i32>,
+ {
+ Bar { inner: 1i32, _marker: () }
+ }
+}
+
+fn copy_tait(x: sus::Tait) -> (sus::Tait, sus::Tait) {
+ (x, x)
+}
+
+fn main() {
+ let bar = sus::Bar { inner: sus::mk_sep(), _marker: () };
+ let (y, z) = copy_tait(bar.into()); // copy a string
+ drop(y.into()); // drop one instance
+ println!("{}", z.into().inner); // print the other
+}
diff --git a/tests/ui/type-alias-impl-trait/hidden_type_mismatch.stderr b/tests/ui/type-alias-impl-trait/hidden_type_mismatch.stderr
new file mode 100644
index 000000000..85e8a600c
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/hidden_type_mismatch.stderr
@@ -0,0 +1,14 @@
+error: concrete type differs from previous defining opaque type use
+ --> $DIR/hidden_type_mismatch.rs:11:20
+ |
+LL | pub type Sep = impl Sized + std::fmt::Display;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, got `String`
+ |
+note: previous use here
+ --> $DIR/hidden_type_mismatch.rs:37:21
+ |
+LL | pub type Tait = impl Copy + From<Bar<()>> + Into<Bar<()>>;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/tests/ui/type-alias-impl-trait/inference-cycle.stderr b/tests/ui/type-alias-impl-trait/inference-cycle.stderr
index 4d5f36747..41530dda9 100644
--- a/tests/ui/type-alias-impl-trait/inference-cycle.stderr
+++ b/tests/ui/type-alias-impl-trait/inference-cycle.stderr
@@ -16,6 +16,7 @@ note: cycle used when checking item types in module `m`
|
LL | mod m {
| ^^^^^
+ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
error[E0391]: cycle detected when computing type of `m::Foo::{opaque#0}`
--> $DIR/inference-cycle.rs:5:20
@@ -34,6 +35,7 @@ note: cycle used when checking item types in module `m`
|
LL | mod m {
| ^^^^^
+ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
error: cannot check whether the hidden type of `inference_cycle[4ecc]::m::Foo::{opaque#0}` satisfies auto traits
--> $DIR/inference-cycle.rs:16:17
diff --git a/tests/ui/type-alias-impl-trait/issue-53092-2.stderr b/tests/ui/type-alias-impl-trait/issue-53092-2.stderr
index 2565a28b4..6148131b4 100644
--- a/tests/ui/type-alias-impl-trait/issue-53092-2.stderr
+++ b/tests/ui/type-alias-impl-trait/issue-53092-2.stderr
@@ -23,6 +23,7 @@ LL | | type Bug<T, U> = impl Fn(T) -> U + Copy;
LL | | CONST_BUG(0);
LL | | }
| |_^
+ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
error[E0277]: the trait bound `U: From<T>` is not satisfied
--> $DIR/issue-53092-2.rs:9:5
diff --git a/tests/ui/type-alias-impl-trait/issue-96572-unconstrained.rs b/tests/ui/type-alias-impl-trait/issue-96572-unconstrained.rs
index 2c740ccc1..fdd8fa65b 100644
--- a/tests/ui/type-alias-impl-trait/issue-96572-unconstrained.rs
+++ b/tests/ui/type-alias-impl-trait/issue-96572-unconstrained.rs
@@ -1,5 +1,7 @@
#![feature(type_alias_impl_trait)]
// check-pass
+// revisions: default edition2021
+//[edition2021] compile-flags: --edition 2021
fn main() {
type T = impl Copy;
diff --git a/tests/ui/type-alias-impl-trait/nested-rpit-with-lifetimes.rs b/tests/ui/type-alias-impl-trait/nested-rpit-with-lifetimes.rs
new file mode 100644
index 000000000..11b659eec
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/nested-rpit-with-lifetimes.rs
@@ -0,0 +1,49 @@
+// Regression test for issue #83190, triggering an ICE in borrowck.
+
+// check-pass
+
+pub trait Any {}
+impl<T> Any for T {}
+
+pub trait StreamOnce {
+ type Range;
+}
+
+pub trait Parser<Input>: Sized {
+ type Output;
+ type PartialState;
+ fn map(self) -> Map<Self> {
+ todo!()
+ }
+}
+
+pub struct Map<P>(P);
+impl<I, P: Parser<I, Output = ()>> Parser<I> for Map<P> {
+ type Output = ();
+ type PartialState = P::PartialState;
+}
+
+struct TakeWhile1<Input>(Input);
+impl<I: StreamOnce> Parser<I> for TakeWhile1<I> {
+ type Output = I::Range;
+ type PartialState = ();
+}
+impl<I> TakeWhile1<I> {
+ fn new() -> Self {
+ todo!()
+ }
+}
+
+impl<I, A: Parser<I>> Parser<I> for (A,) {
+ type Output = ();
+ type PartialState = Map<A::Output>;
+}
+
+pub fn metric_stream_parser<'a, I>() -> impl Parser<I, Output = (), PartialState = impl Any + 'a>
+where
+ I: StreamOnce<Range = &'a [()]>,
+{
+ (TakeWhile1::new(),).map()
+}
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/nested-tait-hrtb.rs b/tests/ui/type-alias-impl-trait/nested-tait-hrtb.rs
new file mode 100644
index 000000000..ba705d6f8
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/nested-tait-hrtb.rs
@@ -0,0 +1,15 @@
+#![feature(type_alias_impl_trait)]
+
+trait Trait<'a> { type Assoc; }
+impl<'a> Trait<'a> for () { type Assoc = &'a str; }
+
+type WithoutLt = impl Sized;
+fn without_lt() -> impl for<'a> Trait<'a, Assoc = WithoutLt> {}
+//~^ ERROR captures lifetime that does not appear in bounds
+
+type WithLt<'a> = impl Sized + 'a;
+
+fn with_lt() -> impl for<'a> Trait<'a, Assoc = WithLt<'a>> {}
+//~^ ERROR expected generic lifetime parameter, found `'a`
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/nested-tait-hrtb.stderr b/tests/ui/type-alias-impl-trait/nested-tait-hrtb.stderr
new file mode 100644
index 000000000..f20873055
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/nested-tait-hrtb.stderr
@@ -0,0 +1,23 @@
+error[E0700]: hidden type for `WithoutLt` captures lifetime that does not appear in bounds
+ --> $DIR/nested-tait-hrtb.rs:7:62
+ |
+LL | type WithoutLt = impl Sized;
+ | ---------- opaque type defined here
+LL | fn without_lt() -> impl for<'a> Trait<'a, Assoc = WithoutLt> {}
+ | -- ^^
+ | |
+ | hidden type `&'a str` captures the lifetime `'a` as defined here
+
+error[E0792]: expected generic lifetime parameter, found `'a`
+ --> $DIR/nested-tait-hrtb.rs:12:60
+ |
+LL | type WithLt<'a> = impl Sized + 'a;
+ | -- this generic parameter must be used with a generic lifetime parameter
+LL |
+LL | fn with_lt() -> impl for<'a> Trait<'a, Assoc = WithLt<'a>> {}
+ | ^^
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0700, E0792.
+For more information about an error, try `rustc --explain E0700`.
diff --git a/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn-2.rs b/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn-2.rs
new file mode 100644
index 000000000..10588398c
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn-2.rs
@@ -0,0 +1,21 @@
+// issue: 113314
+
+#![feature(type_alias_impl_trait)]
+
+type Op = impl std::fmt::Display;
+fn foo() -> Op { &"hello world" }
+
+fn transform<S>() -> impl std::fmt::Display {
+ &0usize
+}
+fn bad() -> Op {
+ transform::<Op>()
+ //~^ ERROR concrete type differs from previous defining opaque type use
+}
+
+fn main() {
+ let mut x = foo();
+ println!("{x}");
+ x = bad();
+ println!("{x}");
+}
diff --git a/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn-2.stderr b/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn-2.stderr
new file mode 100644
index 000000000..7481557fc
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn-2.stderr
@@ -0,0 +1,14 @@
+error: concrete type differs from previous defining opaque type use
+ --> $DIR/recursive-tait-conflicting-defn-2.rs:12:5
+ |
+LL | transform::<Op>()
+ | ^^^^^^^^^^^^^^^^^ expected `&'static &'static str`, got `impl std::fmt::Display`
+ |
+note: previous use here
+ --> $DIR/recursive-tait-conflicting-defn-2.rs:6:18
+ |
+LL | fn foo() -> Op { &"hello world" }
+ | ^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn.rs b/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn.rs
new file mode 100644
index 000000000..e221f4f3f
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn.rs
@@ -0,0 +1,34 @@
+// issue: 113596
+
+#![feature(type_alias_impl_trait)]
+
+trait Test {}
+
+struct A;
+
+impl Test for A {}
+
+struct B<T> {
+ inner: T,
+}
+
+impl<T: Test> Test for B<T> {}
+
+type TestImpl = impl Test;
+
+fn test() -> TestImpl {
+ A
+}
+
+fn make_option() -> Option<TestImpl> {
+ Some(test())
+}
+
+fn make_option2() -> Option<TestImpl> {
+ let inner = make_option().unwrap();
+
+ Some(B { inner })
+ //~^ ERROR concrete type differs from previous defining opaque type use
+}
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn.stderr b/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn.stderr
new file mode 100644
index 000000000..e4209643b
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn.stderr
@@ -0,0 +1,14 @@
+error: concrete type differs from previous defining opaque type use
+ --> $DIR/recursive-tait-conflicting-defn.rs:30:3
+ |
+LL | Some(B { inner })
+ | ^^^^^^^^^^^^^^^^^ expected `A`, got `B<TestImpl>`
+ |
+note: previous use here
+ --> $DIR/recursive-tait-conflicting-defn.rs:20:3
+ |
+LL | A
+ | ^
+
+error: aborting due to previous error
+
diff --git a/tests/ui/type-alias-impl-trait/reveal_local.stderr b/tests/ui/type-alias-impl-trait/reveal_local.stderr
index 0c5ef4a6f..813185c13 100644
--- a/tests/ui/type-alias-impl-trait/reveal_local.stderr
+++ b/tests/ui/type-alias-impl-trait/reveal_local.stderr
@@ -22,6 +22,7 @@ LL | |
LL | |
LL | | fn main() {}
| |____________^
+ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
error[E0391]: cycle detected when computing type of `Foo::{opaque#0}`
--> $DIR/reveal_local.rs:5:12
@@ -46,6 +47,7 @@ LL | |
LL | |
LL | | fn main() {}
| |____________^
+ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
error: cannot check whether the hidden type of `reveal_local[9507]::Foo::{opaque#0}` satisfies auto traits
--> $DIR/reveal_local.rs:15:15
@@ -92,6 +94,7 @@ LL | |
LL | |
LL | | fn main() {}
| |____________^
+ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
error: cannot check whether the hidden type of `reveal_local[9507]::Foo::{opaque#0}` satisfies auto traits
--> $DIR/reveal_local.rs:25:15
diff --git a/tests/ui/type-alias-impl-trait/unconstrained-impl-param.rs b/tests/ui/type-alias-impl-trait/unconstrained-impl-param.rs
new file mode 100644
index 000000000..b35100670
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/unconstrained-impl-param.rs
@@ -0,0 +1,25 @@
+#![feature(type_alias_impl_trait)]
+
+use std::fmt::Display;
+
+type Opaque<X> = impl Sized + 'static;
+fn define<X>() -> Opaque<X> {}
+
+trait Trait {
+ type Assoc: Display;
+}
+impl<'a> Trait for Opaque<&'a str> {
+ //~^ ERROR the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates
+ type Assoc = &'a str;
+}
+
+// ======= Exploit =======
+
+fn extend<T: Trait + 'static>(s: T::Assoc) -> Box<dyn Display> {
+ Box::new(s)
+}
+
+fn main() {
+ let val = extend::<Opaque<&'_ str>>(&String::from("blah blah blah"));
+ println!("{}", val);
+}
diff --git a/tests/ui/type-alias-impl-trait/unconstrained-impl-param.stderr b/tests/ui/type-alias-impl-trait/unconstrained-impl-param.stderr
new file mode 100644
index 000000000..65139307f
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/unconstrained-impl-param.stderr
@@ -0,0 +1,9 @@
+error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates
+ --> $DIR/unconstrained-impl-param.rs:11:6
+ |
+LL | impl<'a> Trait for Opaque<&'a str> {
+ | ^^ unconstrained lifetime parameter
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0207`.
diff --git a/tests/ui/type-alias-impl-trait/under-binder.rs b/tests/ui/type-alias-impl-trait/under-binder.rs
new file mode 100644
index 000000000..caf21d640
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/under-binder.rs
@@ -0,0 +1,9 @@
+#![feature(type_alias_impl_trait)]
+
+type Opaque<'a> = impl Sized + 'a;
+
+fn test(f: fn(u8)) -> fn(Opaque<'_>) {
+ f //~ ERROR E0792
+}
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/under-binder.stderr b/tests/ui/type-alias-impl-trait/under-binder.stderr
new file mode 100644
index 000000000..82c4ec973
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/under-binder.stderr
@@ -0,0 +1,12 @@
+error[E0792]: expected generic lifetime parameter, found `'_`
+ --> $DIR/under-binder.rs:6:5
+ |
+LL | type Opaque<'a> = impl Sized + 'a;
+ | -- this generic parameter must be used with a generic lifetime parameter
+...
+LL | f
+ | ^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0792`.
diff --git a/tests/ui/type-alias-impl-trait/wf-check-rpit-lifetimes.rs b/tests/ui/type-alias-impl-trait/wf-check-rpit-lifetimes.rs
new file mode 100644
index 000000000..b92e15aad
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/wf-check-rpit-lifetimes.rs
@@ -0,0 +1,19 @@
+//check-pass
+
+pub struct Key;
+#[derive(Clone)]
+pub struct Value;
+
+use std::collections::HashMap;
+
+pub struct DiagnosticBuilder<'db> {
+ inner: HashMap<&'db Key, Vec<&'db Value>>,
+}
+
+impl<'db> DiagnosticBuilder<'db> {
+ pub fn iter<'a>(&'a self) -> impl Iterator<Item = (&'db Key, impl Iterator<Item = &'a Value>)> {
+ self.inner.iter().map(|(key, values)| (*key, values.iter().map(|v| *v)))
+ }
+}
+
+fn main() {}