about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-12-17 22:34:43 +0100
committerGitHub <noreply@github.com>2024-12-17 22:34:43 +0100
commit53635e55476980a458e14d3fb3b101446d451d9c (patch)
tree158246eac8414a933a3d1a91bb5f7b7774d5936d
parent264566fc613d38400a6a421f0f1fef21f25e5c9f (diff)
parenta7f61cad1e6735b7f6a522ee1a3bc96c4e9ab1c7 (diff)
Rollup merge of #134408 - rmehri01:rpit-inherits-lifetime, r=compiler-errors
Regression test for RPIT inheriting lifetime from projection

Regression test to close https://github.com/rust-lang/rust/issues/51525
-rw-r--r--tests/ui/impl-trait/rpit/inherits-lifetime.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/ui/impl-trait/rpit/inherits-lifetime.rs b/tests/ui/impl-trait/rpit/inherits-lifetime.rs
new file mode 100644
index 00000000000..60c2a96c873
--- /dev/null
+++ b/tests/ui/impl-trait/rpit/inherits-lifetime.rs
@@ -0,0 +1,24 @@
+//! Check that lifetimes are inherited in RPIT.
+//! Previously, the hidden lifetime of T::Bar would be overlooked
+//! and would instead end up as <T as Foo<'static>>::Bar.
+//!
+//! Regression test for <https://github.com/rust-lang/rust/issues/51525>.
+
+//@ check-pass
+
+trait Foo<'a> {
+    type Bar;
+}
+
+impl<'a> Foo<'a> for u32 {
+    type Bar = &'a ();
+}
+
+fn baz<'a, T>() -> impl IntoIterator<Item = T::Bar>
+where
+    T: Foo<'a>,
+{
+    None
+}
+
+fn main() {}