Skip to content

Commit 6cfa6e2

Browse files
committed
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
1 parent 34a5ea9 commit 6cfa6e2

File tree

1 file changed

+38
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)