Skip to content

Add a new check-pass UI test for returning impl Fn(T) -> impl Trait #136971

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 15, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions tests/ui/impl-trait/impl-fn-rpit-opaque-107883.rs
Original file line number Diff line number Diff line change
@@ -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() {}
Loading