File: missing_arguments.rs

package info (click to toggle)
rustc 1.85.0%2Bdfsg3-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, forky, sid, trixie, trixie-backports, trixie-proposed-updates
  • size: 893,396 kB
  • sloc: xml: 158,127; python: 35,830; javascript: 19,497; cpp: 19,002; sh: 17,245; ansic: 13,127; asm: 4,376; makefile: 1,051; perl: 29; lisp: 29; ruby: 19; sql: 11
file content (40 lines) | stat: -rw-r--r-- 1,806 bytes parent folder | download | duplicates (19)
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
fn one_arg(_a: i32) {}
fn two_same(_a: i32, _b: i32) {}
fn two_diff(_a: i32, _b: f32) {}
fn three_same(_a: i32, _b: i32, _c: i32) {}
fn three_diff(_a: i32, _b: f32, _c: &str) {}
fn four_repeated(_a: i32, _b: f32, _c: f32, _d: &str) {}
fn complex(_a: i32, _b: f32, _c: i32, _d: f32, _e: &str) {}

fn main() {
  one_arg(); //~ ERROR function takes
  // The headers here show the types expected,
  // with formatting to emphasize which arguments are missing
  /*         i32     f32    */
  two_same(               ); //~ ERROR function takes
  two_same(   1           ); //~ ERROR function takes
  two_diff(               ); //~ ERROR function takes
  two_diff(   1           ); //~ ERROR function takes
  two_diff(          1.0  ); //~ ERROR function takes

  /*           i32     i32     i32    */
  three_same(                       ); //~ ERROR function takes
  three_same(   1                   ); //~ ERROR function takes
  three_same(   1,      1           ); //~ ERROR function takes

  /*           i32     f32     &str   */
  three_diff(          1.0,     ""  ); //~ ERROR function takes
  three_diff(   1,              ""  ); //~ ERROR function takes
  three_diff(   1,     1.0          ); //~ ERROR function takes
  three_diff(                   ""  ); //~ ERROR function takes
  three_diff(          1.0          ); //~ ERROR function takes
  three_diff(   1                   ); //~ ERROR function takes

  /*              i32     f32     f32     &str   */
  four_repeated(                               ); //~ ERROR function takes
  four_repeated(   1,                     ""   ); //~ ERROR function takes

  /*        i32   f32   i32   f32   &str   */
  complex(                               ); //~ ERROR function takes
  complex(   1,                     ""   ); //~ ERROR function takes
}