Skip to content

Commit

Permalink
Unrolled build for rust-lang#132303
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#132303 - nyurik:non-exhaustive-err, r=compiler-errors

More tests for non-exhaustive C-like enums in FFI

Add a few more tests for the `improper_ctypes` lint as found with the [varnish-rs](https://github.com/gquintard/varnish-rs) project.

This follows up on rust-lang#116831, fixed in rust-lang#116863 by ``@workingjubilee`` - I have been seeing these fail with the bindgen-generated non-exhaustive enums inside other structs. Seems the issue does not exist in the primary branch, so this PR just makes sure more cases are covered for the future.
  • Loading branch information
rust-timer authored Nov 5, 2024
2 parents 96477c5 + a645342 commit e247203
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,9 @@ pub enum NonExhaustiveCLikeEnum {
Four = 4,
Five = 5,
}

#[repr(C)]
pub struct NormalStructWithNonExhaustiveCLikeEnum {
one: u8,
two: NonExhaustiveCLikeEnum,
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ extern crate types;

use types::{
NonExhaustiveCLikeEnum, NonExhaustiveEnum, NonExhaustiveVariants,
NormalStruct, TupleStruct, UnitStruct,
NormalStruct, TupleStruct, UnitStruct, NormalStructWithNonExhaustiveCLikeEnum
};

extern "C" {
Expand All @@ -27,6 +27,9 @@ extern "C" {
// These should pass without remark, as they're C-compatible, despite being "non-exhaustive".
extern "C" {
pub fn non_exhaustive_c_compat_enum(_: NonExhaustiveCLikeEnum);
pub fn non_exhaustive_c_compat_enum_ret() -> *mut NonExhaustiveCLikeEnum;
pub fn struct_w_non_exhaustive_c_like_enum(_: NormalStructWithNonExhaustiveCLikeEnum);
pub fn struct_w_non_exhaustive_c_like_enum_ret() -> *mut NormalStructWithNonExhaustiveCLikeEnum;
}

fn main() {}

0 comments on commit e247203

Please sign in to comment.