Skip to content

Commit 1db70e1

Browse files
committed
Add test for futures with HRTB
1 parent 0928a1f commit 1db70e1

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// edition:2021
2+
// revisions: classic next
3+
//[next] compile-flags: -Ztrait-solver=next
4+
//[next] check-pass
5+
6+
#![feature(unboxed_closures)]
7+
8+
use std::future::Future;
9+
10+
trait Trait {
11+
fn func(&self, _: &str);
12+
}
13+
14+
impl<T> Trait for T
15+
where
16+
for<'a> T: Fn<(&'a str,)> + Send + Sync,
17+
for<'a> <T as FnOnce<(&'a str,)>>::Output: Future<Output = usize> + Send,
18+
{
19+
fn func(&self, _: &str) {
20+
println!("hello!");
21+
}
22+
}
23+
24+
async fn strlen(x: &str) -> usize {
25+
x.len()
26+
}
27+
28+
fn main() {
29+
strlen.func("hi");
30+
}

0 commit comments

Comments
 (0)