forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#133538 - dev-ardi:69232-better-diag, r=comp…
…iler-errors Better diagnostic for fn items in variadic functions closes rust-lang#69232
- Loading branch information
Showing
9 changed files
with
75 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// https://github.com/rust-lang/rust/issues/69232 | ||
|
||
extern "C" { | ||
fn foo(x: usize, ...); | ||
} | ||
|
||
fn test() -> u8 { | ||
127 | ||
} | ||
|
||
fn main() { | ||
unsafe { foo(1, test) }; //~ ERROR can't pass a function item to a variadic function | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
error[E0617]: can't pass a function item to a variadic function | ||
--> $DIR/fn-item-diagnostic-issue-69232.rs:12:21 | ||
| | ||
LL | unsafe { foo(1, test) }; | ||
| ^^^^ | ||
| | ||
= help: a function item is zero-sized and needs to be cast into a function pointer to be used in FFI | ||
= note: for more information on function items, visit https://doc.rust-lang.org/reference/types/function-item.html | ||
help: use a function pointer instead | ||
| | ||
LL | unsafe { foo(1, test as fn() -> u8) }; | ||
| +++++++++++++ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0617`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters