Skip to content

Commit bfc6ca8

Browse files
More tests
1 parent 75a8f68 commit bfc6ca8

File tree

2 files changed

+91
-0
lines changed

2 files changed

+91
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// build-pass
2+
// edition:2021
3+
// compile-flags: -Cdebuginfo=2
4+
5+
// We were not normalizing opaques with escaping bound vars during codegen,
6+
// leading to later errors during debuginfo computation.
7+
8+
#![feature(async_fn_in_trait)]
9+
10+
#[derive(Clone, Copy)]
11+
pub struct SharedState {}
12+
13+
pub trait State {
14+
async fn execute(self, shared_state: &SharedState);
15+
}
16+
17+
pub trait StateComposer {
18+
fn and_then<T, F>(self, map_fn: F) -> AndThen<Self, F>
19+
where
20+
Self: State + Sized,
21+
T: State,
22+
F: FnOnce() -> T,
23+
{
24+
AndThen { previous: self, map_fn }
25+
}
26+
}
27+
28+
impl<T> StateComposer for T where T: State {}
29+
pub struct AndThen<T, F> {
30+
previous: T,
31+
map_fn: F,
32+
}
33+
34+
impl<T, U, F> State for AndThen<T, F>
35+
where
36+
T: State,
37+
U: State,
38+
F: FnOnce() -> U,
39+
{
40+
async fn execute(self, shared_state: &SharedState)
41+
where
42+
Self: Sized,
43+
{
44+
self.previous.execute(shared_state).await;
45+
(self.map_fn)().execute(shared_state).await
46+
}
47+
}
48+
49+
pub struct SomeState {}
50+
51+
impl State for SomeState {
52+
async fn execute(self, shared_state: &SharedState) {}
53+
}
54+
55+
pub fn main() {
56+
let shared_state = SharedState {};
57+
async {
58+
SomeState {}
59+
.and_then(|| SomeState {})
60+
.and_then(|| SomeState {})
61+
.execute(&shared_state)
62+
.await;
63+
};
64+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// build-pass
2+
// edition:2021
3+
// compile-flags: -Cdebuginfo=2
4+
5+
// We were not normalizing opaques with escaping bound vars during codegen,
6+
// leading to later linker errors because of differences in mangled symbol name.
7+
8+
fn func<T>() -> impl Sized {}
9+
10+
trait Trait<'a> {
11+
type Assoc;
12+
13+
fn call() {
14+
let _ = async {
15+
let _value = func::<Self::Assoc>();
16+
std::future::ready(()).await
17+
};
18+
}
19+
}
20+
21+
impl Trait<'static> for () {
22+
type Assoc = ();
23+
}
24+
25+
fn main() {
26+
<()>::call();
27+
}

0 commit comments

Comments
 (0)