mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
Add test for issue 28994
This commit is contained in:
parent
3afb7d687c
commit
b27c22d6b0
22
tests/ui/traits/fn-pointer/hrtb-assoc-fn-traits-28994.rs
Normal file
22
tests/ui/traits/fn-pointer/hrtb-assoc-fn-traits-28994.rs
Normal file
@ -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);
|
||||
}
|
Loading…
Reference in New Issue
Block a user