2022-10-23 23:11:25 +00:00
|
|
|
error[E0045]: C-variadic function must have a compatible calling convention, like `C` or `cdecl`
|
2021-06-11 11:22:13 +00:00
|
|
|
--> $DIR/variadic-ffi-1.rs:9:5
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | fn printf(_: *const u8, ...);
|
2022-08-08 13:31:32 +00:00
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadic function must have a compatible calling convention
|
2018-08-08 12:28:26 +00:00
|
|
|
|
2020-02-06 05:08:07 +00:00
|
|
|
error[E0060]: this function takes at least 2 arguments but 0 arguments were supplied
|
2022-08-08 13:31:32 +00:00
|
|
|
--> $DIR/variadic-ffi-1.rs:22:9
|
2019-04-19 22:37:34 +00:00
|
|
|
|
|
|
|
|
LL | foo();
|
Implementation for 65853
This attempts to bring better error messages to invalid method calls, by applying some heuristics to identify common mistakes.
The algorithm is inspired by Levenshtein distance and longest common sub-sequence. In essence, we treat the types of the function, and the types of the arguments you provided as two "words" and compute the edits to get from one to the other.
We then modify that algorithm to detect 4 cases:
- A function input is missing
- An extra argument was provided
- The type of an argument is straight up invalid
- Two arguments have been swapped
- A subset of the arguments have been shuffled
(We detect the last two as separate cases so that we can detect two swaps, instead of 4 parameters permuted.)
It helps to understand this argument by paying special attention to terminology: "inputs" refers to the inputs being *expected* by the function, and "arguments" refers to what has been provided at the call site.
The basic sketch of the algorithm is as follows:
- Construct a boolean grid, with a row for each argument, and a column for each input. The cell [i, j] is true if the i'th argument could satisfy the j'th input.
- If we find an argument that could satisfy no inputs, provided for an input that can't be satisfied by any other argument, we consider this an "invalid type".
- Extra arguments are those that can't satisfy any input, provided for an input that *could* be satisfied by another argument.
- Missing inputs are inputs that can't be satisfied by any argument, where the provided argument could satisfy another input
- Swapped / Permuted arguments are identified with a cycle detection algorithm.
As each issue is found, we remove the relevant inputs / arguments and check for more issues. If we find no issues, we match up any "valid" arguments, and start again.
Note that there's a lot of extra complexity:
- We try to stay efficient on the happy path, only computing the diagonal until we find a problem, and then filling in the rest of the matrix.
- Closure arguments are wrapped in a tuple and need to be unwrapped
- We need to resolve closure types after the rest, to allow the most specific type constraints
- We need to handle imported C functions that might be variadic in their inputs.
I tried to document a lot of this in comments in the code and keep the naming clear.
2022-01-22 04:50:54 +00:00
|
|
|
| ^^^-- two arguments of type `isize` and `u8` are missing
|
2020-09-24 02:43:32 +00:00
|
|
|
|
|
|
|
|
note: function defined here
|
2022-08-08 13:31:32 +00:00
|
|
|
--> $DIR/variadic-ffi-1.rs:15:8
|
2020-09-24 02:43:32 +00:00
|
|
|
|
|
|
|
|
LL | fn foo(f: isize, x: u8, ...);
|
|
|
|
| ^^^
|
Implementation for 65853
This attempts to bring better error messages to invalid method calls, by applying some heuristics to identify common mistakes.
The algorithm is inspired by Levenshtein distance and longest common sub-sequence. In essence, we treat the types of the function, and the types of the arguments you provided as two "words" and compute the edits to get from one to the other.
We then modify that algorithm to detect 4 cases:
- A function input is missing
- An extra argument was provided
- The type of an argument is straight up invalid
- Two arguments have been swapped
- A subset of the arguments have been shuffled
(We detect the last two as separate cases so that we can detect two swaps, instead of 4 parameters permuted.)
It helps to understand this argument by paying special attention to terminology: "inputs" refers to the inputs being *expected* by the function, and "arguments" refers to what has been provided at the call site.
The basic sketch of the algorithm is as follows:
- Construct a boolean grid, with a row for each argument, and a column for each input. The cell [i, j] is true if the i'th argument could satisfy the j'th input.
- If we find an argument that could satisfy no inputs, provided for an input that can't be satisfied by any other argument, we consider this an "invalid type".
- Extra arguments are those that can't satisfy any input, provided for an input that *could* be satisfied by another argument.
- Missing inputs are inputs that can't be satisfied by any argument, where the provided argument could satisfy another input
- Swapped / Permuted arguments are identified with a cycle detection algorithm.
As each issue is found, we remove the relevant inputs / arguments and check for more issues. If we find no issues, we match up any "valid" arguments, and start again.
Note that there's a lot of extra complexity:
- We try to stay efficient on the happy path, only computing the diagonal until we find a problem, and then filling in the rest of the matrix.
- Closure arguments are wrapped in a tuple and need to be unwrapped
- We need to resolve closure types after the rest, to allow the most specific type constraints
- We need to handle imported C functions that might be variadic in their inputs.
I tried to document a lot of this in comments in the code and keep the naming clear.
2022-01-22 04:50:54 +00:00
|
|
|
help: provide the arguments
|
|
|
|
|
|
2022-06-19 22:10:42 +00:00
|
|
|
LL | foo(/* isize */, /* u8 */);
|
2022-09-02 02:17:44 +00:00
|
|
|
| ~~~~~~~~~~~~~~~~~~~~~~~
|
2019-04-19 22:37:34 +00:00
|
|
|
|
2020-02-06 05:08:07 +00:00
|
|
|
error[E0060]: this function takes at least 2 arguments but 1 argument was supplied
|
2022-08-08 13:31:32 +00:00
|
|
|
--> $DIR/variadic-ffi-1.rs:23:9
|
2019-04-19 22:37:34 +00:00
|
|
|
|
|
|
|
|
LL | foo(1);
|
Implementation for 65853
This attempts to bring better error messages to invalid method calls, by applying some heuristics to identify common mistakes.
The algorithm is inspired by Levenshtein distance and longest common sub-sequence. In essence, we treat the types of the function, and the types of the arguments you provided as two "words" and compute the edits to get from one to the other.
We then modify that algorithm to detect 4 cases:
- A function input is missing
- An extra argument was provided
- The type of an argument is straight up invalid
- Two arguments have been swapped
- A subset of the arguments have been shuffled
(We detect the last two as separate cases so that we can detect two swaps, instead of 4 parameters permuted.)
It helps to understand this argument by paying special attention to terminology: "inputs" refers to the inputs being *expected* by the function, and "arguments" refers to what has been provided at the call site.
The basic sketch of the algorithm is as follows:
- Construct a boolean grid, with a row for each argument, and a column for each input. The cell [i, j] is true if the i'th argument could satisfy the j'th input.
- If we find an argument that could satisfy no inputs, provided for an input that can't be satisfied by any other argument, we consider this an "invalid type".
- Extra arguments are those that can't satisfy any input, provided for an input that *could* be satisfied by another argument.
- Missing inputs are inputs that can't be satisfied by any argument, where the provided argument could satisfy another input
- Swapped / Permuted arguments are identified with a cycle detection algorithm.
As each issue is found, we remove the relevant inputs / arguments and check for more issues. If we find no issues, we match up any "valid" arguments, and start again.
Note that there's a lot of extra complexity:
- We try to stay efficient on the happy path, only computing the diagonal until we find a problem, and then filling in the rest of the matrix.
- Closure arguments are wrapped in a tuple and need to be unwrapped
- We need to resolve closure types after the rest, to allow the most specific type constraints
- We need to handle imported C functions that might be variadic in their inputs.
I tried to document a lot of this in comments in the code and keep the naming clear.
2022-01-22 04:50:54 +00:00
|
|
|
| ^^^--- an argument of type `u8` is missing
|
2020-09-24 02:43:32 +00:00
|
|
|
|
|
|
|
|
note: function defined here
|
2022-08-08 13:31:32 +00:00
|
|
|
--> $DIR/variadic-ffi-1.rs:15:8
|
2020-09-24 02:43:32 +00:00
|
|
|
|
|
|
|
|
LL | fn foo(f: isize, x: u8, ...);
|
|
|
|
| ^^^
|
Implementation for 65853
This attempts to bring better error messages to invalid method calls, by applying some heuristics to identify common mistakes.
The algorithm is inspired by Levenshtein distance and longest common sub-sequence. In essence, we treat the types of the function, and the types of the arguments you provided as two "words" and compute the edits to get from one to the other.
We then modify that algorithm to detect 4 cases:
- A function input is missing
- An extra argument was provided
- The type of an argument is straight up invalid
- Two arguments have been swapped
- A subset of the arguments have been shuffled
(We detect the last two as separate cases so that we can detect two swaps, instead of 4 parameters permuted.)
It helps to understand this argument by paying special attention to terminology: "inputs" refers to the inputs being *expected* by the function, and "arguments" refers to what has been provided at the call site.
The basic sketch of the algorithm is as follows:
- Construct a boolean grid, with a row for each argument, and a column for each input. The cell [i, j] is true if the i'th argument could satisfy the j'th input.
- If we find an argument that could satisfy no inputs, provided for an input that can't be satisfied by any other argument, we consider this an "invalid type".
- Extra arguments are those that can't satisfy any input, provided for an input that *could* be satisfied by another argument.
- Missing inputs are inputs that can't be satisfied by any argument, where the provided argument could satisfy another input
- Swapped / Permuted arguments are identified with a cycle detection algorithm.
As each issue is found, we remove the relevant inputs / arguments and check for more issues. If we find no issues, we match up any "valid" arguments, and start again.
Note that there's a lot of extra complexity:
- We try to stay efficient on the happy path, only computing the diagonal until we find a problem, and then filling in the rest of the matrix.
- Closure arguments are wrapped in a tuple and need to be unwrapped
- We need to resolve closure types after the rest, to allow the most specific type constraints
- We need to handle imported C functions that might be variadic in their inputs.
I tried to document a lot of this in comments in the code and keep the naming clear.
2022-01-22 04:50:54 +00:00
|
|
|
help: provide the argument
|
|
|
|
|
|
2022-06-19 22:10:42 +00:00
|
|
|
LL | foo(1, /* u8 */);
|
2022-09-02 02:17:44 +00:00
|
|
|
| ~~~~~~~~~~~~~
|
2019-04-19 22:37:34 +00:00
|
|
|
|
|
|
|
error[E0308]: mismatched types
|
2022-08-08 13:31:32 +00:00
|
|
|
--> $DIR/variadic-ffi-1.rs:25:56
|
2019-04-19 22:37:34 +00:00
|
|
|
|
|
|
|
|
LL | let x: unsafe extern "C" fn(f: isize, x: u8) = foo;
|
2019-11-19 05:00:24 +00:00
|
|
|
| ------------------------------------- ^^^ expected non-variadic fn, found variadic function
|
|
|
|
| |
|
|
|
|
| expected due to this
|
2019-04-19 22:37:34 +00:00
|
|
|
|
|
2019-11-24 00:01:20 +00:00
|
|
|
= note: expected fn pointer `unsafe extern "C" fn(_, _)`
|
|
|
|
found fn item `unsafe extern "C" fn(_, _, ...) {foo}`
|
2019-04-19 22:37:34 +00:00
|
|
|
|
|
|
|
error[E0308]: mismatched types
|
2022-08-08 13:31:32 +00:00
|
|
|
--> $DIR/variadic-ffi-1.rs:26:54
|
2019-04-19 22:37:34 +00:00
|
|
|
|
|
|
|
|
LL | let y: extern "C" fn(f: isize, x: u8, ...) = bar;
|
2019-11-19 05:00:24 +00:00
|
|
|
| ----------------------------------- ^^^ expected variadic fn, found non-variadic function
|
|
|
|
| |
|
|
|
|
| expected due to this
|
2019-04-19 22:37:34 +00:00
|
|
|
|
|
2019-11-24 00:01:20 +00:00
|
|
|
= note: expected fn pointer `extern "C" fn(_, _, ...)`
|
|
|
|
found fn item `extern "C" fn(_, _) {bar}`
|
2019-04-19 22:37:34 +00:00
|
|
|
|
|
|
|
error[E0617]: can't pass `f32` to variadic function
|
2022-08-08 13:31:32 +00:00
|
|
|
--> $DIR/variadic-ffi-1.rs:28:19
|
2019-04-19 22:37:34 +00:00
|
|
|
|
|
|
|
|
LL | foo(1, 2, 3f32);
|
|
|
|
| ^^^^ help: cast the value to `c_double`: `3f32 as c_double`
|
|
|
|
|
|
|
|
error[E0617]: can't pass `bool` to variadic function
|
2022-08-08 13:31:32 +00:00
|
|
|
--> $DIR/variadic-ffi-1.rs:29:19
|
2019-04-19 22:37:34 +00:00
|
|
|
|
|
|
|
|
LL | foo(1, 2, true);
|
|
|
|
| ^^^^ help: cast the value to `c_int`: `true as c_int`
|
|
|
|
|
|
|
|
error[E0617]: can't pass `i8` to variadic function
|
2022-08-08 13:31:32 +00:00
|
|
|
--> $DIR/variadic-ffi-1.rs:30:19
|
2019-04-19 22:37:34 +00:00
|
|
|
|
|
|
|
|
LL | foo(1, 2, 1i8);
|
|
|
|
| ^^^ help: cast the value to `c_int`: `1i8 as c_int`
|
|
|
|
|
|
|
|
error[E0617]: can't pass `u8` to variadic function
|
2022-08-08 13:31:32 +00:00
|
|
|
--> $DIR/variadic-ffi-1.rs:31:19
|
2019-04-19 22:37:34 +00:00
|
|
|
|
|
|
|
|
LL | foo(1, 2, 1u8);
|
|
|
|
| ^^^ help: cast the value to `c_uint`: `1u8 as c_uint`
|
|
|
|
|
|
|
|
error[E0617]: can't pass `i16` to variadic function
|
2022-08-08 13:31:32 +00:00
|
|
|
--> $DIR/variadic-ffi-1.rs:32:19
|
2019-04-19 22:37:34 +00:00
|
|
|
|
|
|
|
|
LL | foo(1, 2, 1i16);
|
|
|
|
| ^^^^ help: cast the value to `c_int`: `1i16 as c_int`
|
|
|
|
|
|
|
|
error[E0617]: can't pass `u16` to variadic function
|
2022-08-08 13:31:32 +00:00
|
|
|
--> $DIR/variadic-ffi-1.rs:33:19
|
2019-04-19 22:37:34 +00:00
|
|
|
|
|
|
|
|
LL | foo(1, 2, 1u16);
|
|
|
|
| ^^^^ help: cast the value to `c_uint`: `1u16 as c_uint`
|
|
|
|
|
|
|
|
error: aborting due to 11 previous errors
|
2018-08-08 12:28:26 +00:00
|
|
|
|
2019-04-19 22:37:34 +00:00
|
|
|
Some errors have detailed explanations: E0045, E0060, E0308, E0617.
|
|
|
|
For more information about an error, try `rustc --explain E0045`.
|