]> git.lizzy.rs Git - rust.git/blob - src/test/ui/argument-suggestions/invalid_arguments.rs
Make some diagnostics not depend on the source of what they reference being available
[rust.git] / src / test / ui / argument-suggestions / invalid_arguments.rs
1 // More nuanced test cases for invalid arguments #65853
2
3 struct X {}
4
5 fn one_arg(_a: i32) {}
6 fn two_arg_same(_a: i32, _b: i32) {}
7 fn two_arg_diff(_a: i32, _b: f32) {}
8 fn three_arg_diff(_a: i32, _b: f32, _c: &str) {}
9 fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {}
10
11 fn main() {
12   // Providing an incorrect argument for a single parameter function
13   one_arg(1.0); //~ ERROR mismatched types
14
15   // Providing one or two invalid arguments to a two parameter function
16   two_arg_same(1, ""); //~ ERROR mismatched types
17   two_arg_same("", 1); //~ ERROR mismatched types
18   two_arg_same("", ""); //~ ERROR arguments to this function are incorrect
19   two_arg_diff(1, ""); //~ ERROR mismatched types
20   two_arg_diff("", 1.0); //~ ERROR mismatched types
21   two_arg_diff("", ""); //~ ERROR arguments to this function are incorrect
22
23   // Providing invalid arguments to a three parameter function
24   three_arg_diff(X{}, 1.0, ""); //~ ERROR mismatched types
25   three_arg_diff(1, X {}, ""); //~ ERROR mismatched types
26   three_arg_diff(1, 1.0, X {}); //~ ERROR mismatched types
27
28   three_arg_diff(X {}, X {}, ""); //~ ERROR arguments to this function are incorrect
29   three_arg_diff(X {}, 1.0, X {}); //~ ERROR arguments to this function are incorrect
30   three_arg_diff(1, X {}, X {}); //~ ERROR arguments to this function are incorrect
31
32   three_arg_diff(X {}, X {}, X {}); //~ ERROR arguments to this function are incorrect
33
34   three_arg_repeat(X {}, 1, ""); //~ ERROR mismatched types
35   three_arg_repeat(1, X {}, ""); //~ ERROR mismatched types
36   three_arg_repeat(1, 1, X {}); //~ ERROR mismatched types
37
38   three_arg_repeat(X {}, X {}, ""); //~ ERROR arguments to this function are incorrect
39   three_arg_repeat(X {}, 1, X {}); //~ ERROR arguments to this function are incorrect
40   three_arg_repeat(1, X {}, X{}); //~ ERROR arguments to this function are incorrect
41
42   three_arg_repeat(X {}, X {}, X {}); //~ ERROR arguments to this function are incorrect
43 }