blob: 9a8b3f4357c05ca908b4b6820b4842331d6cf956 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
// Repro for <https://github.com/rust-lang/rust/issues/130113#issue-2512517191>.
//@ edition: 2021
//@ revisions: assumptions no_assumptions
//@[assumptions] compile-flags: -Zhigher-ranked-assumptions
//@[assumptions] check-pass
//@[no_assumptions] known-bug: #110338
use std::future::Future;
fn main() {
let call_me = Wrap(CallMeImpl { value: "test" });
assert_send(async {
call_me.call().await;
});
}
pub fn assert_send<F>(_future: F)
where
F: Future + Send,
{
}
pub trait CallMe {
fn call(&self) -> impl Future<Output = ()> + Send;
}
struct Wrap<T>(T);
impl<S> CallMe for Wrap<S>
where
S: CallMe + Send,
{
// adding `+ Send` to this RPIT fixes the issue
fn call(&self) -> impl Future<Output = ()> {
self.0.call()
}
}
#[derive(Debug, Clone, Copy)]
pub struct CallMeImpl<T> {
value: T,
}
impl<T> CallMe for CallMeImpl<T>
where
// Can replace `Send` by `ToString`, `Clone`, whatever. When removing the
// `Send` bound, the compiler produces a higher-ranked lifetime error.
T: Send + 'static,
{
fn call(&self) -> impl Future<Output = ()> {
async {}
}
}
|