summary refs log tree commit diff
path: root/src/test/ui/argument-suggestions/invalid_arguments.rs
blob: aea445d945754658afb6ad798c1cf3c2619f7049 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// More nuanced test cases for invalid arguments #65853

struct X {}

fn one_arg(_a: i32) {}
fn two_arg_same(_a: i32, _b: i32) {}
fn two_arg_diff(_a: i32, _b: f32) {}
fn three_arg_diff(_a: i32, _b: f32, _c: &str) {}
fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {}

fn main() {
  // Providing an incorrect argument for a single parameter function
  one_arg(1.0); //~ ERROR mismatched types

  // Providing one or two invalid arguments to a two parameter function
  two_arg_same(1, ""); //~ ERROR mismatched types
  two_arg_same("", 1); //~ ERROR mismatched types
  two_arg_same("", "");
  //~^ ERROR mismatched types
  //~| ERROR mismatched types
  two_arg_diff(1, ""); //~ ERROR mismatched types
  two_arg_diff("", 1.0); //~ ERROR mismatched types
  two_arg_diff("", "");
  //~^ ERROR mismatched types
  //~| ERROR mismatched types
  // Providing invalid arguments to a three parameter function
  three_arg_diff(X{}, 1.0, ""); //~ ERROR mismatched types
  three_arg_diff(1, X {}, ""); //~ ERROR mismatched types
  three_arg_diff(1, 1.0, X {}); //~ ERROR mismatched types

  three_arg_diff(X {}, X {}, "");
  //~^ ERROR mismatched types
  //~| ERROR mismatched types
  three_arg_diff(X {}, 1.0, X {});
  //~^ ERROR mismatched types
  //~| ERROR mismatched types
  three_arg_diff(1, X {}, X {});
  //~^ ERROR mismatched types
  //~| ERROR mismatched types

  three_arg_diff(X {}, X {}, X {});
  //~^ ERROR mismatched types
  //~| ERROR mismatched types
  //~| ERROR mismatched types

  three_arg_repeat(X {}, 1, ""); //~ ERROR mismatched types
  three_arg_repeat(1, X {}, ""); //~ ERROR mismatched types
  three_arg_repeat(1, 1, X {}); //~ ERROR mismatched types

  three_arg_repeat(X {}, X {}, "");
  //~^ ERROR mismatched types
  //~| ERROR mismatched types
  three_arg_repeat(X {}, 1, X {});
  //~^ ERROR mismatched types
  //~| ERROR mismatched types
  three_arg_repeat(1, X {}, X{});
  //~^ ERROR mismatched types
  //~| ERROR mismatched types

  three_arg_repeat(X {}, X {}, X {});
  //~^ ERROR mismatched types
  //~| ERROR mismatched types
  //~| ERROR mismatched types
}