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#108611 - davidtwco:issue-94223-external-abi…
…-fn-ptr-in-internal-abi-fn, r=jackh726 lint/ctypes: ext. abi fn-ptr in internal abi fn Fixes rust-lang#94223. - In the improper ctypes lint, instead of skipping functions with internal ABIs, check that the signature doesn't contain any fn-ptr types with external ABIs that aren't FFI-safe. - When computing the ABI for fn-ptr types, remove an `unwrap` that assumed FFI-safe types in foreign fn-ptr types. - I'm not certain that this is the correct approach.
- Loading branch information
Showing
7 changed files
with
333 additions
and
22 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,8 @@ | ||
// check-pass | ||
#![allow(improper_ctypes_definitions)] | ||
#![crate_type = "lib"] | ||
|
||
// Check that computing the fn abi for `bad`, with a external ABI fn ptr that is not FFI-safe, does | ||
// not ICE. | ||
|
||
pub fn bad(f: extern "C" fn([u8])) {} |
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,42 @@ | ||
#![crate_type = "lib"] | ||
#![deny(improper_ctypes_definitions)] | ||
|
||
pub fn bad(f: extern "C" fn([u8])) {} | ||
//~^ ERROR `extern` fn uses type `[u8]`, which is not FFI-safe | ||
|
||
pub fn bad_twice(f: Result<extern "C" fn([u8]), extern "C" fn([u8])>) {} | ||
//~^ ERROR `extern` fn uses type `[u8]`, which is not FFI-safe | ||
//~^^ ERROR `extern` fn uses type `[u8]`, which is not FFI-safe | ||
|
||
struct BadStruct(extern "C" fn([u8])); | ||
//~^ ERROR `extern` fn uses type `[u8]`, which is not FFI-safe | ||
|
||
enum BadEnum { | ||
A(extern "C" fn([u8])), | ||
//~^ ERROR `extern` fn uses type `[u8]`, which is not FFI-safe | ||
} | ||
|
||
enum BadUnion { | ||
A(extern "C" fn([u8])), | ||
//~^ ERROR `extern` fn uses type `[u8]`, which is not FFI-safe | ||
} | ||
|
||
type Foo = extern "C" fn([u8]); | ||
//~^ ERROR `extern` fn uses type `[u8]`, which is not FFI-safe | ||
|
||
pub struct FfiUnsafe; | ||
|
||
#[allow(improper_ctypes_definitions)] | ||
extern "C" fn f(_: FfiUnsafe) { | ||
unimplemented!() | ||
} | ||
|
||
pub static BAD: extern "C" fn(FfiUnsafe) = f; | ||
//~^ ERROR `extern` fn uses type `FfiUnsafe`, which is not FFI-safe | ||
|
||
pub static BAD_TWICE: Result<extern "C" fn(FfiUnsafe), extern "C" fn(FfiUnsafe)> = Ok(f); | ||
//~^ ERROR `extern` fn uses type `FfiUnsafe`, which is not FFI-safe | ||
//~^^ ERROR `extern` fn uses type `FfiUnsafe`, which is not FFI-safe | ||
|
||
pub const BAD_CONST: extern "C" fn(FfiUnsafe) = f; | ||
//~^ ERROR `extern` fn uses type `FfiUnsafe`, which is not FFI-safe |
Oops, something went wrong.