Skip to content

Commit 4e77c3a

Browse files
committed
test: Add test for issues 45510 and 18952.
Those tests are directly taken from the comments on the bug reports.
1 parent 7155690 commit 4e77c3a

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed

src/test/run-pass/issue-18952.rs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// This issue tests fn_traits overloading on arity.
2+
3+
#![feature(fn_traits)]
4+
#![feature(unboxed_closures)]
5+
6+
struct Foo;
7+
8+
impl Fn<(isize, isize)> for Foo {
9+
extern "rust-call" fn call(&self, args: (isize, isize)) -> Self::Output {
10+
println!("{:?}", args);
11+
}
12+
}
13+
14+
impl FnMut<(isize, isize)> for Foo {
15+
extern "rust-call" fn call_mut(&mut self, args: (isize, isize)) -> Self::Output {
16+
println!("{:?}", args);
17+
}
18+
}
19+
20+
impl FnOnce<(isize, isize)> for Foo {
21+
type Output = ();
22+
extern "rust-call" fn call_once(self, args: (isize, isize)) -> Self::Output {
23+
println!("{:?}", args);
24+
}
25+
}
26+
27+
impl Fn<(isize, isize, isize)> for Foo {
28+
extern "rust-call" fn call(&self, args: (isize, isize, isize)) -> Self::Output {
29+
println!("{:?}", args);
30+
}
31+
}
32+
33+
impl FnMut<(isize, isize, isize)> for Foo {
34+
extern "rust-call" fn call_mut(&mut self, args: (isize, isize, isize)) -> Self::Output {
35+
println!("{:?}", args);
36+
}
37+
}
38+
impl FnOnce<(isize, isize, isize)> for Foo {
39+
type Output = ();
40+
extern "rust-call" fn call_once(self, args: (isize, isize, isize)) -> Self::Output {
41+
println!("{:?}", args);
42+
}
43+
}
44+
45+
fn main() {
46+
let foo = Foo;
47+
foo(1, 1);
48+
}

src/test/run-pass/issue-45510.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Test overloaded resolution of fn_traits.
2+
3+
#![feature(fn_traits)]
4+
#![feature(unboxed_closures)]
5+
6+
struct Ishmael;
7+
struct Maybe;
8+
struct CallMe;
9+
10+
impl FnOnce<(Ishmael,)> for CallMe {
11+
type Output = ();
12+
extern "rust-call" fn call_once(self, _args: (Ishmael,)) -> () {
13+
println!("Split your lungs with blood and thunder!");
14+
}
15+
}
16+
17+
impl FnOnce<(Maybe,)> for CallMe {
18+
type Output = ();
19+
extern "rust-call" fn call_once(self, _args: (Maybe,)) -> () {
20+
println!("So we just met, and this is crazy");
21+
}
22+
}
23+
24+
fn main() {
25+
CallMe(Ishmael);
26+
CallMe(Maybe);
27+
}

0 commit comments

Comments
 (0)