Skip to content

Commit 202c11b

Browse files
authored
Rollup merge of #99307 - JohnTitor:issue-64401, r=compiler-errors
Add regression test for #64401 Closes #64401 r? `@compiler-errors` Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2 parents 083a253 + 6465980 commit 202c11b

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

src/test/ui/codegen/issue-64401.rs

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// build-pass
2+
// The ICE didn't happen with `cargo check` but `cargo build`.
3+
4+
use std::marker::PhantomData;
5+
6+
trait Owned<'a> {
7+
type Reader;
8+
}
9+
10+
impl<'a> Owned<'a> for () {
11+
type Reader = ();
12+
}
13+
14+
trait Handler {
15+
fn handle(&self);
16+
}
17+
18+
struct CtxHandlerWithoutState<M, F> {
19+
message_type: PhantomData<M>,
20+
_function: F,
21+
}
22+
23+
impl<M, F> CtxHandlerWithoutState<M, F> {
24+
pub fn new(_function: F) -> Self {
25+
Self {
26+
message_type: PhantomData,
27+
_function,
28+
}
29+
}
30+
}
31+
32+
impl<'a, M, F> Handler for CtxHandlerWithoutState<M, F>
33+
where
34+
F: Fn(<M as Owned<'a>>::Reader),
35+
M: Owned<'a>,
36+
{
37+
fn handle(&self) {}
38+
}
39+
40+
fn e_to_i<M: for<'a> Owned<'a>>(_: <M as Owned<'_>>::Reader) {}
41+
42+
fn send_external_to_internal<M>()
43+
where
44+
M: for<'a> Owned<'a>,
45+
{
46+
let _: Box<dyn Handler> = Box::new(CtxHandlerWithoutState::<M, _>::new(e_to_i::<M>));
47+
}
48+
49+
fn main() {
50+
send_external_to_internal::<()>()
51+
}

0 commit comments

Comments
 (0)