1
Fork 0

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>
This commit is contained in:
Xelph 2025-02-13 04:37:32 -07:00
parent 34a5ea911c
commit 7d1262adf2

View file

@ -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() {}