]> git.proxmox.com Git - rustc.git/blob - src/test/ui/mismatched_types/overloaded-calls-bad.rs
New upstream version 1.67.1+dfsg1
[rustc.git] / src / test / ui / mismatched_types / overloaded-calls-bad.rs
1 #![feature(fn_traits, unboxed_closures)]
2
3 use std::ops::FnMut;
4
5 struct S {
6 x: isize,
7 y: isize,
8 }
9
10 impl FnMut<(isize,)> for S {
11 extern "rust-call" fn call_mut(&mut self, (z,): (isize,)) -> isize {
12 self.x * self.y * z
13 }
14 }
15
16 impl FnOnce<(isize,)> for S {
17 type Output = isize;
18 extern "rust-call" fn call_once(mut self, (z,): (isize,)) -> isize {
19 self.call_mut((z,))
20 }
21 }
22
23 struct F;
24
25 impl FnOnce<(i32,)> for F {
26 type Output = ();
27
28 extern "rust-call" fn call_once(self, args: (i32,)) -> Self::Output {}
29 }
30
31 fn main() {
32 let mut s = S { x: 3, y: 3 };
33 let ans = s("what");
34 //~^ ERROR mismatched types
35 let ans = s();
36 //~^ ERROR this function takes 1 argument but 0 arguments were supplied
37 let ans = s("burma", "shave");
38 //~^ ERROR this function takes 1 argument but 2 arguments were supplied
39
40 F("");
41 //~^ ERROR mismatched types
42 }