diff --git a/tests/ui/async-await/async-closures/unifying-function-types-involving-hrtb.rs b/tests/ui/async-await/async-closures/unifying-function-types-involving-hrtb.rs new file mode 100644 index 0000000000000..05505206b7139 --- /dev/null +++ b/tests/ui/async-await/async-closures/unifying-function-types-involving-hrtb.rs @@ -0,0 +1,33 @@ +//! Regresssion test for . + +//@ edition:2018 +//@ check-pass + +use std::future::Future; + +trait Foo<'a> { + type Future: Future + 'a; + + fn start(self, f: &'a u8) -> Self::Future; +} + +impl<'a, Fn, Fut> Foo<'a> for Fn +where + Fn: FnOnce(&'a u8) -> Fut, + Fut: Future + 'a, +{ + type Future = Fut; + + fn start(self, f: &'a u8) -> Self::Future { (self)(f) } +} + +fn foo(f: F) where F: for<'a> Foo<'a> { + let bar = 5; + f.start(&bar); +} + +fn main() { + foo(async move | f: &u8 | { *f }); + + foo({ async fn baz(f: &u8) -> u8 { *f } baz }); +}