about summary refs log tree commit diff
path: root/tests/ui/impl-trait/impl-fn-rpit-opaque-107883.rs
blob: 3655bff63eb0cad3b961e0f6e82cd246b65434df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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() {}