diff options
| author | Xelph <fierrosalinas.la@gmail.com> | 2025-02-13 04:37:32 -0700 |
|---|---|---|
| committer | Xelph <fierrosalinas.la@gmail.com> | 2025-02-14 05:55:30 -0700 |
| commit | 7d1262adf271f2c7f1438e327f18f87d681bb537 (patch) | |
| tree | 723cd864a499a6a5bad0b921a22ce430c5800460 | |
| parent | 34a5ea911c56e79bd451c63f04ea2f5023d7d1a3 (diff) | |
Add new ui test for returning an Fn trait that returns impl Trait
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 <waffle.lapkin@gmail.com>
| -rw-r--r-- | tests/ui/impl-trait/impl-fn-rpit-opaque-107883.rs | 37 |
1 files changed, 37 insertions, 0 deletions
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 00000000000..3655bff63eb --- /dev/null +++ b/tests/ui/impl-trait/impl-fn-rpit-opaque-107883.rs @@ -0,0 +1,37 @@ +//@ check-pass +// Regression test for <https;//github.com/rust-lang/rust/issues/107883> +#![feature(impl_trait_in_fn_trait_return)] +#![feature(unboxed_closures)] // only for `h` + +use std::fmt::Debug; + +fn f<T>() -> impl Fn(T) -> impl Debug { + |_x| 15 +} + +fn g<T>() -> impl MyFn<(T,), Out = impl Debug> { + |_x| 15 +} + +trait MyFn<T> { + type Out; +} + +impl<T, U, F: Fn(T) -> U> MyFn<(T,)> for F { + type Out = U; +} + +fn h<T>() -> impl Fn<(T,), Output = impl Debug> { + |_x| 15 +} + +fn f_<T>() -> impl Fn(T) -> impl Debug { + std::convert::identity(|_x| 15) +} + +fn f__<T>() -> impl Fn(T) -> impl Debug { + let r = |_x| 15; + r +} + +fn main() {} |
