Skip to content

Commit 0514de7

Browse files
authored
checker: fix struct field init with generic anon fn (add the test from #18294) (#20888)
1 parent 10c2f9e commit 0514de7

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
pub struct Module {
2+
}
3+
4+
pub struct Service {
5+
callback fn () = unsafe { nil }
6+
}
7+
8+
pub fn (mut self Module) do_anything[T]() {
9+
}
10+
11+
pub fn (mut self Module) register[T]() {
12+
_ := Service{
13+
callback: fn [mut self] [T]() {
14+
self.do_anything[T]()
15+
}
16+
}
17+
}
18+
19+
struct Something {
20+
}
21+
22+
struct SomethingDifferent {
23+
}
24+
25+
fn test_struct_field_init_with_generic_anon_fn() {
26+
mut mod := Module{}
27+
mod.register[Something]()
28+
mod.register[SomethingDifferent]()
29+
assert true
30+
}

0 commit comments

Comments
 (0)