diff options
| author | clubby789 <jamie@hill-daniel.co.uk> | 2024-10-07 11:32:53 +0000 |
|---|---|---|
| committer | clubby789 <jamie@hill-daniel.co.uk> | 2024-10-07 16:30:47 +0000 |
| commit | b27c22d6b0a230fc122d541356580f0fb2be2366 (patch) | |
| tree | fa1e42596d252204eb9ed5618b70306f0b70c638 | |
| parent | 3afb7d687c17518684f3aa4a42909e2b1d9887be (diff) | |
| download | rust-b27c22d6b0a230fc122d541356580f0fb2be2366.tar.gz rust-b27c22d6b0a230fc122d541356580f0fb2be2366.zip | |
Add test for issue 28994
| -rw-r--r-- | tests/ui/traits/fn-pointer/hrtb-assoc-fn-traits-28994.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/ui/traits/fn-pointer/hrtb-assoc-fn-traits-28994.rs b/tests/ui/traits/fn-pointer/hrtb-assoc-fn-traits-28994.rs new file mode 100644 index 00000000000..e2f02053f95 --- /dev/null +++ b/tests/ui/traits/fn-pointer/hrtb-assoc-fn-traits-28994.rs @@ -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); +} |
