Skip to content

Commit efc38ca

Browse files
committed
Add new ui test for returning an Fn trait that returns impl Trait
1 parent 34a5ea9 commit efc38ca

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

tests/ui/idk-what-to-call-this.rs

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//@ check-pass
2+
//compiletest for #107883: Returning `impl Fn(T) -> impl Trait`
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)