-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #55672 - RalfJung:miri-extern-types, r=eddyb
miri: accept extern types in structs if they are the only field Fixes #55541 Cc @oli-obk @eddyb #43467
- Loading branch information
Showing
3 changed files
with
53 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// compile-pass | ||
|
||
// Test that we can handle newtypes wrapping extern types | ||
|
||
#![feature(extern_types, const_transmute)] | ||
|
||
use std::marker::PhantomData; | ||
|
||
extern "C" { | ||
pub type ExternType; | ||
} | ||
unsafe impl Sync for ExternType {} | ||
static MAGIC_FFI_STATIC: u8 = 42; | ||
|
||
#[repr(transparent)] | ||
pub struct Wrapper(ExternType); | ||
pub static MAGIC_FFI_REF: &'static Wrapper = unsafe { | ||
std::mem::transmute(&MAGIC_FFI_STATIC) | ||
}; | ||
|
||
#[repr(transparent)] | ||
pub struct Wrapper2(PhantomData<Vec<i32>>, ExternType); | ||
pub static MAGIC_FFI_REF2: &'static Wrapper2 = unsafe { | ||
std::mem::transmute(&MAGIC_FFI_STATIC) | ||
}; | ||
|
||
fn main() {} |