Skip to content

Commit

Permalink
Add test for issue 28994
Browse files Browse the repository at this point in the history
  • Loading branch information
clubby789 committed Oct 7, 2024
1 parent 3afb7d6 commit b27c22d
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/ui/traits/fn-pointer/hrtb-assoc-fn-traits-28994.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//@ check-pass
//! Tests that a HRTB + FnOnce bound involving an associated type don't prevent
//! a function pointer from implementing `Fn` traits.
//! Test for <https://github.com/rust-lang/rust/issues/28994>
trait LifetimeToType<'a> {
type Out;
}

impl<'a> LifetimeToType<'a> for () {
type Out = &'a ();
}

fn id<'a>(val: &'a ()) -> <() as LifetimeToType<'a>>::Out {
val
}

fn assert_fn<F: for<'a> FnOnce(&'a ()) -> <() as LifetimeToType<'a>>::Out>(_func: F) { }

fn main() {
assert_fn(id);
}

0 comments on commit b27c22d

Please sign in to comment.