Skip to content

Commit 91c155b

Browse files
committed
Change return types and check return values in tests.
This allows to verify that we handle different types as return types, and that we call the expected functions.
1 parent 2530ce9 commit 91c155b

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

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

+10-3
Original file line numberDiff line numberDiff line change
@@ -9,41 +9,48 @@ struct Foo;
99
impl Fn<(isize, isize)> for Foo {
1010
extern "rust-call" fn call(&self, args: (isize, isize)) -> Self::Output {
1111
println!("{:?}", args);
12+
(args.0 + 1, args.1 + 1)
1213
}
1314
}
1415

1516
impl FnMut<(isize, isize)> for Foo {
1617
extern "rust-call" fn call_mut(&mut self, args: (isize, isize)) -> Self::Output {
1718
println!("{:?}", args);
19+
(args.0 + 1, args.1 + 1)
1820
}
1921
}
2022

2123
impl FnOnce<(isize, isize)> for Foo {
22-
type Output = ();
24+
type Output = (isize, isize);
2325
extern "rust-call" fn call_once(self, args: (isize, isize)) -> Self::Output {
2426
println!("{:?}", args);
27+
(args.0 + 1, args.1 + 1)
2528
}
2629
}
2730

2831
impl Fn<(isize, isize, isize)> for Foo {
2932
extern "rust-call" fn call(&self, args: (isize, isize, isize)) -> Self::Output {
3033
println!("{:?}", args);
34+
(args.0 + 3, args.1 + 3, args.2 + 3)
3135
}
3236
}
3337

3438
impl FnMut<(isize, isize, isize)> for Foo {
3539
extern "rust-call" fn call_mut(&mut self, args: (isize, isize, isize)) -> Self::Output {
3640
println!("{:?}", args);
41+
(args.0 + 3, args.1 + 3, args.2 + 3)
3742
}
3843
}
3944
impl FnOnce<(isize, isize, isize)> for Foo {
40-
type Output = ();
45+
type Output = (isize, isize, isize);
4146
extern "rust-call" fn call_once(self, args: (isize, isize, isize)) -> Self::Output {
4247
println!("{:?}", args);
48+
(args.0 + 3, args.1 + 3, args.2 + 3)
4349
}
4450
}
4551

4652
fn main() {
4753
let foo = Foo;
48-
foo(1, 1);
54+
assert_eq!(foo(1, 1), (2, 2));
55+
assert_eq!(foo(1, 1, 1), (4, 4, 4));
4956
}

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

+10-6
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,29 @@
44
#![feature(fn_traits)]
55
#![feature(unboxed_closures)]
66

7+
#[derive(Debug, PartialEq, Eq)]
78
struct Ishmael;
9+
#[derive(Debug, PartialEq, Eq)]
810
struct Maybe;
911
struct CallMe;
1012

1113
impl FnOnce<(Ishmael,)> for CallMe {
12-
type Output = ();
13-
extern "rust-call" fn call_once(self, _args: (Ishmael,)) -> () {
14+
type Output = Ishmael;
15+
extern "rust-call" fn call_once(self, _args: (Ishmael,)) -> Ishmael {
1416
println!("Split your lungs with blood and thunder!");
17+
Ishmael
1518
}
1619
}
1720

1821
impl FnOnce<(Maybe,)> for CallMe {
19-
type Output = ();
20-
extern "rust-call" fn call_once(self, _args: (Maybe,)) -> () {
22+
type Output = Maybe;
23+
extern "rust-call" fn call_once(self, _args: (Maybe,)) -> Maybe {
2124
println!("So we just met, and this is crazy");
25+
Maybe
2226
}
2327
}
2428

2529
fn main() {
26-
CallMe(Ishmael);
27-
CallMe(Maybe);
30+
assert_eq!(CallMe(Ishmael), Ishmael);
31+
assert_eq!(CallMe(Maybe), Maybe);
2832
}

0 commit comments

Comments
 (0)