Skip to content

Commit 7d1262a

Browse files
LFS6502WaffleLapkin
andcommitted
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) <[email protected]> Improve test name, location, and description Update tests/ui/impl-trait/impl-fn-rpit-opaque-107883.rs Co-authored-by: waffle <[email protected]>
1 parent 34a5ea9 commit 7d1262a

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//@ check-pass
2+
// Regression test for <https;//github.com/rust-lang/rust/issues/107883>
3+
#![feature(impl_trait_in_fn_trait_return)]
4+
#![feature(unboxed_closures)] // only for `h`
5+
6+
use std::fmt::Debug;
7+
8+
fn f<T>() -> impl Fn(T) -> impl Debug {
9+
|_x| 15
10+
}
11+
12+
fn g<T>() -> impl MyFn<(T,), Out = impl Debug> {
13+
|_x| 15
14+
}
15+
16+
trait MyFn<T> {
17+
type Out;
18+
}
19+
20+
impl<T, U, F: Fn(T) -> U> MyFn<(T,)> for F {
21+
type Out = U;
22+
}
23+
24+
fn h<T>() -> impl Fn<(T,), Output = impl Debug> {
25+
|_x| 15
26+
}
27+
28+
fn f_<T>() -> impl Fn(T) -> impl Debug {
29+
std::convert::identity(|_x| 15)
30+
}
31+
32+
fn f__<T>() -> impl Fn(T) -> impl Debug {
33+
let r = |_x| 15;
34+
r
35+
}
36+
37+
fn main() {}

0 commit comments

Comments
 (0)