From 7d1262adf271f2c7f1438e327f18f87d681bb537 Mon Sep 17 00:00:00 2001 From: Xelph Date: Thu, 13 Feb 2025 04:37:32 -0700 Subject: [PATCH] Add new ui test for returning an Fn trait that returns impl Trait MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change description from compiletest to regression test Co-authored-by: 许杰友 Jieyou Xu (Joe) <39484203+jieyouxu@users.noreply.github.com> Improve test name, location, and description Update tests/ui/impl-trait/impl-fn-rpit-opaque-107883.rs Co-authored-by: waffle --- .../impl-trait/impl-fn-rpit-opaque-107883.rs | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tests/ui/impl-trait/impl-fn-rpit-opaque-107883.rs diff --git a/tests/ui/impl-trait/impl-fn-rpit-opaque-107883.rs b/tests/ui/impl-trait/impl-fn-rpit-opaque-107883.rs new file mode 100644 index 0000000000000..3655bff63eb0c --- /dev/null +++ b/tests/ui/impl-trait/impl-fn-rpit-opaque-107883.rs @@ -0,0 +1,37 @@ +//@ check-pass +// Regression test for +#![feature(impl_trait_in_fn_trait_return)] +#![feature(unboxed_closures)] // only for `h` + +use std::fmt::Debug; + +fn f() -> impl Fn(T) -> impl Debug { + |_x| 15 +} + +fn g() -> impl MyFn<(T,), Out = impl Debug> { + |_x| 15 +} + +trait MyFn { + type Out; +} + +impl U> MyFn<(T,)> for F { + type Out = U; +} + +fn h() -> impl Fn<(T,), Output = impl Debug> { + |_x| 15 +} + +fn f_() -> impl Fn(T) -> impl Debug { + std::convert::identity(|_x| 15) +} + +fn f__() -> impl Fn(T) -> impl Debug { + let r = |_x| 15; + r +} + +fn main() {}