fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #69854 - pietroalbini:stable-next, r=Centrilb8cedc00407

1.42.0
3.0 KiB86 linesraw
1error[E0045]: C-variadic function must have C or cdecl calling convention
2  --> $DIR/variadic-ffi-1.rs:5:5
3   |
4LL |     fn printf(_: *const u8, ...);
5   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadics require C or cdecl calling convention
6
7error[E0060]: this function takes at least 2 parameters but 0 parameters were supplied
8  --> $DIR/variadic-ffi-1.rs:16:9
9   |
10LL |     fn foo(f: isize, x: u8, ...);
11   |     ----------------------------- defined here
12...
13LL |         foo();
14   |         ^^^^^ expected at least 2 parameters
15
16error[E0060]: this function takes at least 2 parameters but 1 parameter was supplied
17  --> $DIR/variadic-ffi-1.rs:17:9
18   |
19LL |     fn foo(f: isize, x: u8, ...);
20   |     ----------------------------- defined here
21...
22LL |         foo(1);
23   |         ^^^^^^ expected at least 2 parameters
24
25error[E0308]: mismatched types
26  --> $DIR/variadic-ffi-1.rs:19:56
27   |
28LL |         let x: unsafe extern "C" fn(f: isize, x: u8) = foo;
29   |                -------------------------------------   ^^^ expected non-variadic fn, found variadic function
30   |                |
31   |                expected due to this
32   |
33   = note: expected fn pointer `unsafe extern "C" fn(_, _)`
34                 found fn item `unsafe extern "C" fn(_, _, ...) {foo}`
35
36error[E0308]: mismatched types
37  --> $DIR/variadic-ffi-1.rs:20:54
38   |
39LL |         let y: extern "C" fn(f: isize, x: u8, ...) = bar;
40   |                -----------------------------------   ^^^ expected variadic fn, found non-variadic function
41   |                |
42   |                expected due to this
43   |
44   = note: expected fn pointer `extern "C" fn(_, _, ...)`
45                 found fn item `extern "C" fn(_, _) {bar}`
46
47error[E0617]: can't pass `f32` to variadic function
48  --> $DIR/variadic-ffi-1.rs:22:19
49   |
50LL |         foo(1, 2, 3f32);
51   |                   ^^^^ help: cast the value to `c_double`: `3f32 as c_double`
52
53error[E0617]: can't pass `bool` to variadic function
54  --> $DIR/variadic-ffi-1.rs:23:19
55   |
56LL |         foo(1, 2, true);
57   |                   ^^^^ help: cast the value to `c_int`: `true as c_int`
58
59error[E0617]: can't pass `i8` to variadic function
60  --> $DIR/variadic-ffi-1.rs:24:19
61   |
62LL |         foo(1, 2, 1i8);
63   |                   ^^^ help: cast the value to `c_int`: `1i8 as c_int`
64
65error[E0617]: can't pass `u8` to variadic function
66  --> $DIR/variadic-ffi-1.rs:25:19
67   |
68LL |         foo(1, 2, 1u8);
69   |                   ^^^ help: cast the value to `c_uint`: `1u8 as c_uint`
70
71error[E0617]: can't pass `i16` to variadic function
72  --> $DIR/variadic-ffi-1.rs:26:19
73   |
74LL |         foo(1, 2, 1i16);
75   |                   ^^^^ help: cast the value to `c_int`: `1i16 as c_int`
76
77error[E0617]: can't pass `u16` to variadic function
78  --> $DIR/variadic-ffi-1.rs:27:19
79   |
80LL |         foo(1, 2, 1u16);
81   |                   ^^^^ help: cast the value to `c_uint`: `1u16 as c_uint`
82
83error: aborting due to 11 previous errors
84
85Some errors have detailed explanations: E0045, E0060, E0308, E0617.
86For more information about an error, try `rustc --explain E0045`.