Rollup merge of #133620 - dev-ardi:simplify-hir_typeck_pass_to_variadic_function, r=compiler-errors
Simplify hir_typeck_pass_to_variadic_function r? ``@compiler-errors`` This reworks a bit how the diagnostic is generated so that it does the same as #133538 The `help` is useless now so I removed it
This commit is contained in:
commit
c112195fec
5 changed files with 69 additions and 27 deletions
|
|
@ -62,37 +62,67 @@ error[E0617]: can't pass `f32` to variadic function
|
|||
--> $DIR/variadic-ffi-1.rs:28:19
|
||||
|
|
||||
LL | foo(1, 2, 3f32);
|
||||
| ^^^^ help: cast the value to `c_double`: `3f32 as c_double`
|
||||
| ^^^^
|
||||
|
|
||||
help: cast the value to `c_double`
|
||||
|
|
||||
LL | foo(1, 2, 3f32 as c_double);
|
||||
| +++++++++++
|
||||
|
||||
error[E0617]: can't pass `bool` to variadic function
|
||||
--> $DIR/variadic-ffi-1.rs:29:19
|
||||
|
|
||||
LL | foo(1, 2, true);
|
||||
| ^^^^ help: cast the value to `c_int`: `true as c_int`
|
||||
| ^^^^
|
||||
|
|
||||
help: cast the value to `c_int`
|
||||
|
|
||||
LL | foo(1, 2, true as c_int);
|
||||
| ++++++++
|
||||
|
||||
error[E0617]: can't pass `i8` to variadic function
|
||||
--> $DIR/variadic-ffi-1.rs:30:19
|
||||
|
|
||||
LL | foo(1, 2, 1i8);
|
||||
| ^^^ help: cast the value to `c_int`: `1i8 as c_int`
|
||||
| ^^^
|
||||
|
|
||||
help: cast the value to `c_int`
|
||||
|
|
||||
LL | foo(1, 2, 1i8 as c_int);
|
||||
| ++++++++
|
||||
|
||||
error[E0617]: can't pass `u8` to variadic function
|
||||
--> $DIR/variadic-ffi-1.rs:31:19
|
||||
|
|
||||
LL | foo(1, 2, 1u8);
|
||||
| ^^^ help: cast the value to `c_uint`: `1u8 as c_uint`
|
||||
| ^^^
|
||||
|
|
||||
help: cast the value to `c_uint`
|
||||
|
|
||||
LL | foo(1, 2, 1u8 as c_uint);
|
||||
| +++++++++
|
||||
|
||||
error[E0617]: can't pass `i16` to variadic function
|
||||
--> $DIR/variadic-ffi-1.rs:32:19
|
||||
|
|
||||
LL | foo(1, 2, 1i16);
|
||||
| ^^^^ help: cast the value to `c_int`: `1i16 as c_int`
|
||||
| ^^^^
|
||||
|
|
||||
help: cast the value to `c_int`
|
||||
|
|
||||
LL | foo(1, 2, 1i16 as c_int);
|
||||
| ++++++++
|
||||
|
||||
error[E0617]: can't pass `u16` to variadic function
|
||||
--> $DIR/variadic-ffi-1.rs:33:19
|
||||
|
|
||||
LL | foo(1, 2, 1u16);
|
||||
| ^^^^ help: cast the value to `c_uint`: `1u16 as c_uint`
|
||||
| ^^^^
|
||||
|
|
||||
help: cast the value to `c_uint`
|
||||
|
|
||||
LL | foo(1, 2, 1u16 as c_uint);
|
||||
| +++++++++
|
||||
|
||||
error: aborting due to 11 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -2,31 +2,56 @@ error[E0617]: can't pass `f32` to variadic function
|
|||
--> $DIR/E0617.rs:7:36
|
||||
|
|
||||
LL | printf(::std::ptr::null(), 0f32);
|
||||
| ^^^^ help: cast the value to `c_double`: `0f32 as c_double`
|
||||
| ^^^^
|
||||
|
|
||||
help: cast the value to `c_double`
|
||||
|
|
||||
LL | printf(::std::ptr::null(), 0f32 as c_double);
|
||||
| +++++++++++
|
||||
|
||||
error[E0617]: can't pass `i8` to variadic function
|
||||
--> $DIR/E0617.rs:10:36
|
||||
|
|
||||
LL | printf(::std::ptr::null(), 0i8);
|
||||
| ^^^ help: cast the value to `c_int`: `0i8 as c_int`
|
||||
| ^^^
|
||||
|
|
||||
help: cast the value to `c_int`
|
||||
|
|
||||
LL | printf(::std::ptr::null(), 0i8 as c_int);
|
||||
| ++++++++
|
||||
|
||||
error[E0617]: can't pass `i16` to variadic function
|
||||
--> $DIR/E0617.rs:13:36
|
||||
|
|
||||
LL | printf(::std::ptr::null(), 0i16);
|
||||
| ^^^^ help: cast the value to `c_int`: `0i16 as c_int`
|
||||
| ^^^^
|
||||
|
|
||||
help: cast the value to `c_int`
|
||||
|
|
||||
LL | printf(::std::ptr::null(), 0i16 as c_int);
|
||||
| ++++++++
|
||||
|
||||
error[E0617]: can't pass `u8` to variadic function
|
||||
--> $DIR/E0617.rs:16:36
|
||||
|
|
||||
LL | printf(::std::ptr::null(), 0u8);
|
||||
| ^^^ help: cast the value to `c_uint`: `0u8 as c_uint`
|
||||
| ^^^
|
||||
|
|
||||
help: cast the value to `c_uint`
|
||||
|
|
||||
LL | printf(::std::ptr::null(), 0u8 as c_uint);
|
||||
| +++++++++
|
||||
|
||||
error[E0617]: can't pass `u16` to variadic function
|
||||
--> $DIR/E0617.rs:19:36
|
||||
|
|
||||
LL | printf(::std::ptr::null(), 0u16);
|
||||
| ^^^^ help: cast the value to `c_uint`: `0u16 as c_uint`
|
||||
| ^^^^
|
||||
|
|
||||
help: cast the value to `c_uint`
|
||||
|
|
||||
LL | printf(::std::ptr::null(), 0u16 as c_uint);
|
||||
| +++++++++
|
||||
|
||||
error[E0617]: can't pass a function item to a variadic function
|
||||
--> $DIR/E0617.rs:22:36
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue