Skip to content

Commit e247203

Browse files
authored
Unrolled build for rust-lang#132303
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.
2 parents 96477c5 + a645342 commit e247203

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

tests/ui/rfcs/rfc-2008-non-exhaustive/improper_ctypes/auxiliary/types.rs

+6
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,9 @@ pub enum NonExhaustiveCLikeEnum {
3838
Four = 4,
3939
Five = 5,
4040
}
41+
42+
#[repr(C)]
43+
pub struct NormalStructWithNonExhaustiveCLikeEnum {
44+
one: u8,
45+
two: NonExhaustiveCLikeEnum,
46+
}

tests/ui/rfcs/rfc-2008-non-exhaustive/improper_ctypes/extern_crate_improper.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ extern crate types;
88

99
use types::{
1010
NonExhaustiveCLikeEnum, NonExhaustiveEnum, NonExhaustiveVariants,
11-
NormalStruct, TupleStruct, UnitStruct,
11+
NormalStruct, TupleStruct, UnitStruct, NormalStructWithNonExhaustiveCLikeEnum
1212
};
1313

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

3235
fn main() {}

0 commit comments

Comments
 (0)